1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** Utility */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_utility_unicode_to_string PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function converts a unicode string to a zero terminated */
44 /* ascii string. */
45 /* */
46 /* INPUT */
47 /* */
48 /* source Unicode String */
49 /* destination Ascii String */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* none */
54 /* */
55 /* CALLS */
56 /* */
57 /* None */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* USBX Components */
62 /* */
63 /* RELEASE HISTORY */
64 /* */
65 /* DATE NAME DESCRIPTION */
66 /* */
67 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
68 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
69 /* resulting in version 6.1 */
70 /* */
71 /**************************************************************************/
_ux_utility_unicode_to_string(UCHAR * source,UCHAR * destination)72 VOID _ux_utility_unicode_to_string(UCHAR *source, UCHAR *destination)
73 {
74 ULONG string_length;
75
76 /* Obtain the length of the unicode string. This is the first byte*/
77 string_length = (ULONG) *source++;
78
79 /* Parse the unicode string. First byte is always 0, second byte is the
80 ASCII character. */
81 while(string_length--)
82 {
83 /* First character is from the source. */
84 *destination++ = *source++;
85
86 /* Second character of unicode word is 0. */
87 source++;
88 }
89
90 /* We are done with the ascii string. Insert a zero at the end. */
91 *destination = 0;
92
93 /* Finished. */
94 return;
95 }
96
97