22// The .NET Foundation licenses this file to you under the MIT license.
33
44/* ++
5-
6-
7-
85Module Name:
9-
106unicode.cpp
117
128Abstract:
13-
149Implementation of all functions related to Unicode support
15-
16- Revision History:
17-
18-
19-
2010--*/
2111
2212#include " pal/thread.hpp"
@@ -27,7 +17,6 @@ Revision History:
2717#include < minipal/utf8.h>
2818#include " pal/cruntime.h"
2919#include " pal/stackstring.hpp"
30- #include " pal/unicodedata.h"
3120
3221#include < pthread.h>
3322#include < locale.h>
@@ -39,138 +28,6 @@ using namespace CorUnix;
3928
4029SET_DEFAULT_DEBUG_CHANNEL (UNICODE);
4130
42- /* ++
43- Function:
44- UnicodeDataComp
45- This is the comparison function used by the bsearch function to search
46- for unicode characters in the UnicodeData array.
47-
48- Parameter:
49- pnKey
50- The unicode character value to search for.
51- elem
52- A pointer to a UnicodeDataRec.
53-
54- Return value:
55- <0 if pnKey < elem->nUnicodeValue
56- 0 if pnKey == elem->nUnicodeValue
57- >0 if pnKey > elem->nUnicodeValue
58- --*/
59- static int UnicodeDataComp (const void *pnKey, const void *elem)
60- {
61- WCHAR uValue = ((UnicodeDataRec*)elem)->nUnicodeValue ;
62-
63- if (*((INT*)pnKey) < uValue)
64- {
65- return -1 ;
66- }
67- else if (*((INT*)pnKey) > uValue)
68- {
69- return 1 ;
70- }
71- else
72- {
73- return 0 ;
74- }
75- }
76-
77- /* ++
78- Function:
79- GetUnicodeData
80- This function is used to get information about a Unicode character.
81-
82- Parameters:
83- nUnicodeValue
84- The numeric value of the Unicode character to get information about.
85- pDataRec
86- The UnicodeDataRec to fill in with the data for the Unicode character.
87-
88- Return value:
89- TRUE if the Unicode character was found.
90-
91- --*/
92- BOOL GetUnicodeData (INT nUnicodeValue, UnicodeDataRec *pDataRec)
93- {
94- BOOL bRet;
95-
96- UnicodeDataRec *dataRec;
97- INT nNumOfChars = UNICODE_DATA_SIZE;
98- dataRec = (UnicodeDataRec *) bsearch (&nUnicodeValue, UnicodeData, nNumOfChars,
99- sizeof (UnicodeDataRec), UnicodeDataComp);
100- if (dataRec == NULL )
101- {
102- bRet = FALSE ;
103- }
104- else
105- {
106- bRet = TRUE ;
107- *pDataRec = *dataRec;
108- }
109- return bRet;
110- }
111-
112- char16_t
113- __cdecl
114- PAL_ToUpperInvariant ( char16_t c )
115- {
116- UnicodeDataRec dataRec;
117-
118- PERF_ENTRY (PAL_ToUpperInvariant);
119- ENTRY (" PAL_ToUpperInvariant (c=%d)\n " , c);
120-
121- if (!GetUnicodeData (c, &dataRec))
122- {
123- TRACE ( " Unable to retrieve unicode data for the character %c.\n " , c );
124- LOGEXIT (" PAL_ToUpperInvariant returns int %d\n " , c );
125- PERF_EXIT (PAL_ToUpperInvariant);
126- return c;
127- }
128-
129- if ( dataRec.nFlag != LOWER_CASE )
130- {
131- LOGEXIT (" PAL_ToUpperInvariant returns int %d\n " , c );
132- PERF_EXIT (PAL_ToUpperInvariant);
133- return c;
134- }
135- else
136- {
137- LOGEXIT (" PAL_ToUpperInvariant returns int %d\n " , dataRec.nOpposingCase );
138- PERF_EXIT (PAL_ToUpperInvariant);
139- return dataRec.nOpposingCase ;
140- }
141- }
142-
143- char16_t
144- __cdecl
145- PAL_ToLowerInvariant ( char16_t c )
146- {
147- UnicodeDataRec dataRec;
148-
149- PERF_ENTRY (PAL_ToLowerInvariant);
150- ENTRY (" PAL_ToLowerInvariant (c=%d)\n " , c);
151-
152- if (!GetUnicodeData (c, &dataRec))
153- {
154- TRACE ( " Unable to retrieve unicode data for the character %c.\n " , c );
155- LOGEXIT (" PAL_ToLowerInvariant returns int %d\n " , c );
156- PERF_EXIT (PAL_ToLowerInvariant);
157- return c;
158- }
159-
160- if ( dataRec.nFlag != UPPER_CASE )
161- {
162- LOGEXIT (" PAL_ToLowerInvariant returns int %d\n " , c );
163- PERF_EXIT (PAL_ToLowerInvariant);
164- return c;
165- }
166- else
167- {
168- LOGEXIT (" PAL_ToLowerInvariant returns int %d\n " , dataRec.nOpposingCase );
169- PERF_EXIT (PAL_ToLowerInvariant);
170- return dataRec.nOpposingCase ;
171- }
172- }
173-
17431/* ++
17532Function:
17633GetConsoleOutputCP
0 commit comments