GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_unicode_to_string.c Lines: 7 7 100.0 %
Date: 2026-03-06 18:57:10 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
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
/**************************************************************************/
64
21
VOID  _ux_utility_unicode_to_string(UCHAR *source, UCHAR *destination)
65
{
66
ULONG   string_length;
67
68
    /* Obtain the length of the unicode string.  This is the first byte*/
69
21
    string_length = (ULONG) *source++;
70
71
    /* Parse the unicode string. First byte is always 0, second byte is the
72
       ASCII character.  */
73
286
    while(string_length--)
74
    {
75
        /* First character is from the source.  */
76
265
        *destination++ = *source++;
77
78
        /* Second character of unicode word is 0.  */
79
265
        source++;
80
    }
81
82
    /* We are done with the ascii string. Insert a zero at the end. */
83
21
    *destination = 0;
84
85
    /* Finished.  */
86
21
    return;
87
}
88