ReactOS 0.4.15-dev-7788-g1ad9096
nls.c File Reference
#include <rtl.h>
#include <debug.h>
Include dependency graph for nls.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI RtlCustomCPToUnicodeN (IN PCPTABLEINFO CustomCP, OUT PWCHAR UnicodeString, IN ULONG UnicodeSize, OUT PULONG ResultSize OPTIONAL, IN PCHAR CustomString, IN ULONG CustomSize)
 
WCHAR NTAPI RtlpDowncaseUnicodeChar (IN WCHAR Source)
 
WCHAR NTAPI RtlDowncaseUnicodeChar (IN WCHAR Source)
 
VOID NTAPI RtlGetDefaultCodePage (OUT PUSHORT AnsiCodePage, OUT PUSHORT OemCodePage)
 
VOID NTAPI RtlInitCodePageTable (IN PUSHORT TableBase, OUT PCPTABLEINFO CodePageTable)
 
VOID NTAPI RtlInitNlsTables (IN PUSHORT AnsiTableBase, IN PUSHORT OemTableBase, IN PUSHORT CaseTableBase, OUT PNLSTABLEINFO NlsTable)
 
NTSTATUS NTAPI RtlMultiByteToUnicodeN (OUT PWCHAR UnicodeString, IN ULONG UnicodeSize, OUT PULONG ResultSize, IN PCSTR MbString, IN ULONG MbSize)
 
NTSTATUS NTAPI RtlConsoleMultiByteToUnicodeN (OUT PWCHAR UnicodeString, IN ULONG UnicodeSize, OUT PULONG ResultSize, IN PCSTR MbString, IN ULONG MbSize, OUT PULONG Unknown)
 
NTSTATUS NTAPI RtlMultiByteToUnicodeSize (OUT PULONG UnicodeSize, IN PCSTR MbString, IN ULONG MbSize)
 
NTSTATUS NTAPI RtlOemToUnicodeN (OUT PWCHAR UnicodeString, IN ULONG UnicodeSize, OUT PULONG ResultSize OPTIONAL, IN PCCH OemString, IN ULONG OemSize)
 
VOID NTAPI RtlResetRtlTranslations (IN PNLSTABLEINFO NlsTable)
 
NTSTATUS NTAPI RtlUnicodeToCustomCPN (IN PCPTABLEINFO CustomCP, OUT PCHAR CustomString, IN ULONG CustomSize, OUT PULONG ResultSize OPTIONAL, IN PWCHAR UnicodeString, IN ULONG UnicodeSize)
 
NTSTATUS NTAPI RtlUnicodeToMultiByteN (OUT PCHAR MbString, IN ULONG MbSize, OUT PULONG ResultSize OPTIONAL, IN PCWCH UnicodeString, IN ULONG UnicodeSize)
 
NTSTATUS NTAPI RtlUnicodeToMultiByteSize (OUT PULONG MbSize, IN PCWCH UnicodeString, IN ULONG UnicodeSize)
 
NTSTATUS NTAPI RtlUnicodeToOemN (OUT PCHAR OemString, IN ULONG OemSize, OUT PULONG ResultSize OPTIONAL, IN PCWCH UnicodeString, IN ULONG UnicodeSize)
 
WCHAR NTAPI RtlpUpcaseUnicodeChar (IN WCHAR Source)
 
WCHAR NTAPI RtlUpcaseUnicodeChar (IN WCHAR Source)
 
NTSTATUS NTAPI RtlUpcaseUnicodeToCustomCPN (IN PCPTABLEINFO CustomCP, OUT PCHAR CustomString, IN ULONG CustomSize, OUT PULONG ResultSize OPTIONAL, IN PWCHAR UnicodeString, IN ULONG UnicodeSize)
 
NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN (OUT PCHAR MbString, IN ULONG MbSize, OUT PULONG ResultSize OPTIONAL, IN PCWCH UnicodeString, IN ULONG UnicodeSize)
 
NTSTATUS NTAPI RtlUpcaseUnicodeToOemN (OUT PCHAR OemString, IN ULONG OemSize, OUT PULONG ResultSize OPTIONAL, IN PCWCH UnicodeString, IN ULONG UnicodeSize)
 
CHAR NTAPI RtlUpperChar (IN CHAR Source)
 

Variables

PUSHORT NlsUnicodeUpcaseTable = NULL
 
PUSHORT NlsUnicodeLowercaseTable = NULL
 
USHORT NlsAnsiCodePage = 0
 
BOOLEAN NlsMbCodePageTag = FALSE
 
PUSHORT NlsAnsiToUnicodeTable = NULL
 
PCHAR NlsUnicodeToAnsiTable = NULL
 
PUSHORT NlsUnicodeToMbAnsiTable = NULL
 
PUSHORT NlsLeadByteInfo = NULL
 
USHORT NlsOemCodePage = 0
 
BOOLEAN NlsMbOemCodePageTag = FALSE
 
PUSHORT NlsOemToUnicodeTable = NULL
 
PCHAR NlsUnicodeToOemTable = NULL
 
PUSHORT NlsUnicodeToMbOemTable = NULL
 
PUSHORT NlsOemLeadByteInfo = NULL
 
USHORT NlsOemDefaultChar = '\0'
 
USHORT NlsUnicodeDefaultChar = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file nls.c.

Function Documentation

◆ RtlConsoleMultiByteToUnicodeN()

NTSTATUS NTAPI RtlConsoleMultiByteToUnicodeN ( OUT PWCHAR  UnicodeString,
IN ULONG  UnicodeSize,
OUT PULONG  ResultSize,
IN PCSTR  MbString,
IN ULONG  MbSize,
OUT PULONG  Unknown 
)

Definition at line 301 of file nls.c.

307{
309
311 DPRINT1("RtlConsoleMultiByteToUnicodeN calling RtlMultiByteToUnicodeN\n");
312 *Unknown = 1;
314 UnicodeSize,
315 ResultSize,
316 MbString,
317 MbSize);
318}
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:115
@ Unknown
Definition: i8042prt.h:114
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
NTSTATUS NTAPI RtlMultiByteToUnicodeN(OUT PWCHAR UnicodeString, IN ULONG UnicodeSize, OUT PULONG ResultSize, IN PCSTR MbString, IN ULONG MbSize)
Definition: nls.c:231

◆ RtlCustomCPToUnicodeN()

NTSTATUS NTAPI RtlCustomCPToUnicodeN ( IN PCPTABLEINFO  CustomCP,
OUT PWCHAR  UnicodeString,
IN ULONG  UnicodeSize,
OUT PULONG ResultSize  OPTIONAL,
IN PCHAR  CustomString,
IN ULONG  CustomSize 
)

Definition at line 45 of file nls.c.

51{
52 ULONG Size = 0;
53 ULONG i;
54
56
57 if (!CustomCP->DBCSCodePage)
58 {
59 /* single-byte code page */
60 if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
61 Size = UnicodeSize / sizeof(WCHAR);
62 else
63 Size = CustomSize;
64
65 if (ResultSize)
66 *ResultSize = Size * sizeof(WCHAR);
67
68 for (i = 0; i < Size; i++)
69 {
70 *UnicodeString = CustomCP->MultiByteTable[(UCHAR)*CustomString];
72 CustomString++;
73 }
74 }
75 else
76 {
77 /* multi-byte code page */
78 /* FIXME */
80 }
81
82 return STATUS_SUCCESS;
83}
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ RtlDowncaseUnicodeChar()

WCHAR NTAPI RtlDowncaseUnicodeChar ( IN WCHAR  Source)

Definition at line 131 of file nls.c.

132{
134
136}
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
WCHAR NTAPI RtlpDowncaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:89

◆ RtlGetDefaultCodePage()

VOID NTAPI RtlGetDefaultCodePage ( OUT PUSHORT  AnsiCodePage,
OUT PUSHORT  OemCodePage 
)

Definition at line 142 of file nls.c.

144{
146
149}
static CODEPAGE_ENTRY AnsiCodePage
Definition: nls.c:46
static CODEPAGE_ENTRY OemCodePage
Definition: nls.c:47
USHORT NlsOemCodePage
Definition: nls.c:28
USHORT NlsAnsiCodePage
Definition: nls.c:21

◆ RtlInitCodePageTable()

VOID NTAPI RtlInitCodePageTable ( IN PUSHORT  TableBase,
OUT PCPTABLEINFO  CodePageTable 
)

Definition at line 155 of file nls.c.

157{
158 PNLS_FILE_HEADER NlsFileHeader;
159
161
162 DPRINT("RtlInitCodePageTable() called\n");
163
164 NlsFileHeader = (PNLS_FILE_HEADER)TableBase;
165
166 /* Copy header fields first */
167 CodePageTable->CodePage = NlsFileHeader->CodePage;
169 CodePageTable->DefaultChar = NlsFileHeader->DefaultChar;
173
175 &NlsFileHeader->LeadByte,
177
178 /* Offset to wide char table is after the header */
180 TableBase + NlsFileHeader->HeaderSize + 1 + TableBase[NlsFileHeader->HeaderSize];
181
182 /* Then multibyte table (256 wchars) follows */
183 CodePageTable->MultiByteTable = TableBase + NlsFileHeader->HeaderSize + 1;
184
185 /* Check the presence of glyph table (256 wchars) */
186 if (!CodePageTable->MultiByteTable[256])
188 else
190
191 /* Is this double-byte code page? */
193 {
196 }
197 else
198 {
201 }
202}
#define NULL
Definition: types.h:112
#define MAXIMUM_LEADBYTES
Definition: precomp.h:16
struct _NLS_FILE_HEADER * PNLS_FILE_HEADER
_Out_ PCPTABLEINFO CodePageTable
Definition: rtlfuncs.h:4316
#define DPRINT
Definition: sndvol32.h:71
USHORT DefaultChar
Definition: precomp.h:34
PUSHORT DBCSRanges
Definition: precomp.h:42
USHORT DBCSCodePage
Definition: precomp.h:38
USHORT TransDefaultChar
Definition: precomp.h:36
PUSHORT MultiByteTable
Definition: precomp.h:40
UCHAR LeadByte[MAXIMUM_LEADBYTES]
Definition: precomp.h:39
USHORT CodePage
Definition: precomp.h:32
PUSHORT DBCSOffsets
Definition: precomp.h:43
USHORT UniDefaultChar
Definition: precomp.h:35
USHORT MaximumCharacterSize
Definition: precomp.h:33
PVOID WideCharTable
Definition: precomp.h:41
USHORT TransUniDefaultChar
Definition: precomp.h:37
USHORT MaximumCharacterSize
Definition: precomp.h:22
UCHAR LeadByte[MAXIMUM_LEADBYTES]
Definition: precomp.h:27
USHORT TransDefaultChar
Definition: precomp.h:25
USHORT HeaderSize
Definition: precomp.h:20
USHORT CodePage
Definition: precomp.h:21
USHORT TransUniDefaultChar
Definition: precomp.h:26
USHORT DefaultChar
Definition: precomp.h:23
USHORT UniDefaultChar
Definition: precomp.h:24
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by IntGetCodePageEntry(), NlsInit(), and RtlInitNlsTables().

◆ RtlInitNlsTables()

VOID NTAPI RtlInitNlsTables ( IN PUSHORT  AnsiTableBase,
IN PUSHORT  OemTableBase,
IN PUSHORT  CaseTableBase,
OUT PNLSTABLEINFO  NlsTable 
)

Definition at line 208 of file nls.c.

212{
214
215 DPRINT("RtlInitNlsTables()called\n");
216
217 if (AnsiTableBase && OemTableBase && CaseTableBase)
218 {
219 RtlInitCodePageTable(AnsiTableBase, &NlsTable->AnsiTableInfo);
220 RtlInitCodePageTable(OemTableBase, &NlsTable->OemTableInfo);
221
222 NlsTable->UpperCaseTable = (PUSHORT)CaseTableBase + 2;
223 NlsTable->LowerCaseTable = (PUSHORT)CaseTableBase + *((PUSHORT)CaseTableBase + 1) + 2;
224 }
225}
VOID NTAPI RtlInitCodePageTable(IN PUSHORT TableBase, OUT PCPTABLEINFO CodePageTable)
Definition: nls.c:155
uint16_t * PUSHORT
Definition: typedefs.h:56

◆ RtlMultiByteToUnicodeN()

NTSTATUS NTAPI RtlMultiByteToUnicodeN ( OUT PWCHAR  UnicodeString,
IN ULONG  UnicodeSize,
OUT PULONG  ResultSize,
IN PCSTR  MbString,
IN ULONG  MbSize 
)

Definition at line 231 of file nls.c.

236{
237 ULONG Size = 0;
238 ULONG i;
239
241
242 if (!NlsMbCodePageTag)
243 {
244 /* single-byte code page */
245 if (MbSize > (UnicodeSize / sizeof(WCHAR)))
246 Size = UnicodeSize / sizeof(WCHAR);
247 else
248 Size = MbSize;
249
250 if (ResultSize)
251 *ResultSize = Size * sizeof(WCHAR);
252
253 for (i = 0; i < Size; i++)
254 {
256 }
257 }
258 else
259 {
260 /* multi-byte code page */
261 /* FIXME */
262
263 UCHAR Char;
264 USHORT LeadByteInfo;
265 PCSTR MbEnd = MbString + MbSize;
266
267 for (i = 0; i < UnicodeSize / sizeof(WCHAR) && MbString < MbEnd; i++)
268 {
269 Char = *(PUCHAR)MbString++;
270
271 if (Char < 0x80)
272 {
273 *UnicodeString++ = Char;
274 continue;
275 }
276
277 LeadByteInfo = NlsLeadByteInfo[Char];
278
279 if (!LeadByteInfo)
280 {
282 continue;
283 }
284
285 if (MbString < MbEnd)
286 *UnicodeString++ = NlsLeadByteInfo[LeadByteInfo + *(PUCHAR)MbString++];
287 }
288
289 if (ResultSize)
290 *ResultSize = i * sizeof(WCHAR);
291 }
292
293 return STATUS_SUCCESS;
294}
unsigned short USHORT
Definition: pedump.c:61
PUSHORT NlsLeadByteInfo
Definition: nls.c:26
PUSHORT NlsAnsiToUnicodeTable
Definition: nls.c:23
BOOLEAN NlsMbCodePageTag
Definition: nls.c:22
const char * PCSTR
Definition: typedefs.h:52
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by RtlConsoleMultiByteToUnicodeN().

◆ RtlMultiByteToUnicodeSize()

NTSTATUS NTAPI RtlMultiByteToUnicodeSize ( OUT PULONG  UnicodeSize,
IN PCSTR  MbString,
IN ULONG  MbSize 
)

Definition at line 325 of file nls.c.

328{
329 ULONG Length = 0;
330
332
333 if (!NlsMbCodePageTag)
334 {
335 /* single-byte code page */
336 *UnicodeSize = MbSize * sizeof(WCHAR);
337 }
338 else
339 {
340 /* multi-byte code page */
341 /* FIXME */
342
343 while (MbSize--)
344 {
345 UCHAR Char = *(PUCHAR)MbString++;
346
347 if (Char >= 0x80 && NlsLeadByteInfo[Char])
348 {
349 if (MbSize)
350 {
351 /* Move on */
352 MbSize--;
353 MbString++;
354 }
355 }
356
357 /* Increase returned size */
358 Length++;
359 }
360
361 /* Return final size */
362 *UnicodeSize = Length * sizeof(WCHAR);
363 }
364
365 /* Success */
366 return STATUS_SUCCESS;
367}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

◆ RtlOemToUnicodeN()

NTSTATUS NTAPI RtlOemToUnicodeN ( OUT PWCHAR  UnicodeString,
IN ULONG  UnicodeSize,
OUT PULONG ResultSize  OPTIONAL,
IN PCCH  OemString,
IN ULONG  OemSize 
)

Definition at line 373 of file nls.c.

378{
379 ULONG Size = 0;
380 ULONG i;
381
383
385 {
386 /* single-byte code page */
387 if (OemSize > (UnicodeSize / sizeof(WCHAR)))
388 Size = UnicodeSize / sizeof(WCHAR);
389 else
390 Size = OemSize;
391
392 if (ResultSize)
393 *ResultSize = Size * sizeof(WCHAR);
394
395 for (i = 0; i < Size; i++)
396 {
399 OemString++;
400 }
401 }
402 else
403 {
404 /* multi-byte code page */
405 /* FIXME */
406
407 UCHAR Char;
408 USHORT OemLeadByteInfo;
409 PCCH OemEnd = OemString + OemSize;
410
411 for (i = 0; i < UnicodeSize / sizeof(WCHAR) && OemString < OemEnd; i++)
412 {
413 Char = *(PUCHAR)OemString++;
414
415 if (Char < 0x80)
416 {
417 *UnicodeString++ = Char;
418 continue;
419 }
420
421 OemLeadByteInfo = NlsOemLeadByteInfo[Char];
422
423 if (!OemLeadByteInfo)
424 {
426 continue;
427 }
428
429 if (OemString < OemEnd)
430 *UnicodeString++ =
431 NlsOemLeadByteInfo[OemLeadByteInfo + *(PUCHAR)OemString++];
432 }
433
434 if (ResultSize)
435 *ResultSize = i * sizeof(WCHAR);
436 }
437
438 return STATUS_SUCCESS;
439}
CONST CHAR * PCCH
Definition: ntbasedef.h:392
PUSHORT NlsOemLeadByteInfo
Definition: nls.c:33
BOOLEAN NlsMbOemCodePageTag
Definition: nls.c:29
PUSHORT NlsOemToUnicodeTable
Definition: nls.c:30
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1560

◆ RtlpDowncaseUnicodeChar()

WCHAR NTAPI RtlpDowncaseUnicodeChar ( IN WCHAR  Source)

Definition at line 89 of file nls.c.

90{
92
94
95 if (Source < L'A')
96 return Source;
97
98 if (Source <= L'Z')
99 return Source + (L'a' - L'A');
100
101 if (Source < 0x80)
102 return Source;
103
104 Offset = ((USHORT)Source >> 8);
105 DPRINT("Offset: %hx\n", Offset);
106
108 DPRINT("Offset: %hx\n", Offset);
109
110 Offset += (((USHORT)Source & 0x00F0) >> 4);
111 DPRINT("Offset: %hx\n", Offset);
112
114 DPRINT("Offset: %hx\n", Offset);
115
116 Offset += ((USHORT)Source & 0x000F);
117 DPRINT("Offset: %hx\n", Offset);
118
120 DPRINT("Offset: %hx\n", Offset);
121
122 DPRINT("Result: %hx\n", Source + (SHORT)Offset);
123
124 return Source + (SHORT)Offset;
125}
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define L(x)
Definition: ntvdm.h:50
short SHORT
Definition: pedump.c:59
PUSHORT NlsUnicodeLowercaseTable
Definition: nls.c:19

Referenced by RtlDowncaseUnicodeChar().

◆ RtlpUpcaseUnicodeChar()

WCHAR NTAPI RtlpUpcaseUnicodeChar ( IN WCHAR  Source)

Definition at line 695 of file nls.c.

696{
698
699 if (Source < 'a')
700 return Source;
701
702 if (Source <= 'z')
703 return (Source - ('a' - 'A'));
704
705 Offset = ((USHORT)Source >> 8) & 0xFF;
707
708 Offset += ((USHORT)Source >> 4) & 0xF;
710
711 Offset += ((USHORT)Source & 0xF);
713
714 return Source + (SHORT)Offset;
715}
PUSHORT NlsUnicodeUpcaseTable
Definition: nls.c:18

Referenced by RtlUpcaseUnicodeChar(), RtlUpcaseUnicodeToCustomCPN(), RtlUpcaseUnicodeToMultiByteN(), RtlUpcaseUnicodeToOemN(), and RtlUpperChar().

◆ RtlResetRtlTranslations()

VOID NTAPI RtlResetRtlTranslations ( IN PNLSTABLEINFO  NlsTable)

Definition at line 445 of file nls.c.

446{
448
449 DPRINT("RtlResetRtlTranslations() called\n");
450
451 /* Set ANSI data */
452 NlsAnsiToUnicodeTable = (PUSHORT)NlsTable->AnsiTableInfo.MultiByteTable;
453 NlsUnicodeToAnsiTable = NlsTable->AnsiTableInfo.WideCharTable;
454 NlsUnicodeToMbAnsiTable = (PUSHORT)NlsTable->AnsiTableInfo.WideCharTable;
455 NlsMbCodePageTag = (NlsTable->AnsiTableInfo.DBCSCodePage != 0);
456 NlsLeadByteInfo = NlsTable->AnsiTableInfo.DBCSOffsets;
457 NlsAnsiCodePage = NlsTable->AnsiTableInfo.CodePage;
458 DPRINT("Ansi codepage %hu\n", NlsAnsiCodePage);
459
460 /* Set OEM data */
461 NlsOemToUnicodeTable = (PUSHORT)NlsTable->OemTableInfo.MultiByteTable;
462 NlsUnicodeToOemTable = NlsTable->OemTableInfo.WideCharTable;
463 NlsUnicodeToMbOemTable = (PUSHORT)NlsTable->OemTableInfo.WideCharTable;
464 NlsMbOemCodePageTag = (NlsTable->OemTableInfo.DBCSCodePage != 0);
465 NlsOemLeadByteInfo = NlsTable->OemTableInfo.DBCSOffsets;
466 NlsOemCodePage = NlsTable->OemTableInfo.CodePage;
467 DPRINT("Oem codepage %hu\n", NlsOemCodePage);
468
469 /* Set Unicode case map data */
470 NlsUnicodeUpcaseTable = NlsTable->UpperCaseTable;
471 NlsUnicodeLowercaseTable = NlsTable->LowerCaseTable;
472
473 /* set the default characters for RtlpDidUnicodeToOemWork */
474 NlsOemDefaultChar = NlsTable->OemTableInfo.DefaultChar;
475 NlsUnicodeDefaultChar = NlsTable->OemTableInfo.TransDefaultChar;
476}
USHORT NlsOemDefaultChar
Definition: nls.c:35
PUSHORT NlsUnicodeToMbOemTable
Definition: nls.c:32
PCHAR NlsUnicodeToAnsiTable
Definition: nls.c:24
USHORT NlsUnicodeDefaultChar
Definition: nls.c:36
PUSHORT NlsUnicodeToMbAnsiTable
Definition: nls.c:25
PCHAR NlsUnicodeToOemTable
Definition: nls.c:31

◆ RtlUnicodeToCustomCPN()

NTSTATUS NTAPI RtlUnicodeToCustomCPN ( IN PCPTABLEINFO  CustomCP,
OUT PCHAR  CustomString,
IN ULONG  CustomSize,
OUT PULONG ResultSize  OPTIONAL,
IN PWCHAR  UnicodeString,
IN ULONG  UnicodeSize 
)

Definition at line 482 of file nls.c.

488{
489 ULONG Size = 0;
490 ULONG i;
491
493
494 if (!CustomCP->DBCSCodePage)
495 {
496 /* single-byte code page */
497 if (UnicodeSize > (CustomSize * sizeof(WCHAR)))
498 Size = CustomSize;
499 else
500 Size = UnicodeSize / sizeof(WCHAR);
501
502 if (ResultSize)
503 *ResultSize = Size;
504
505 for (i = 0; i < Size; i++)
506 {
507 *CustomString = ((PCHAR)CustomCP->WideCharTable)[*UnicodeString];
508 CustomString++;
510 }
511 }
512 else
513 {
514 /* multi-byte code page */
515 /* FIXME */
516 ASSERT(FALSE);
517 }
518
519 return STATUS_SUCCESS;
520}
#define PCHAR
Definition: match.c:90

◆ RtlUnicodeToMultiByteN()

NTSTATUS NTAPI RtlUnicodeToMultiByteN ( OUT PCHAR  MbString,
IN ULONG  MbSize,
OUT PULONG ResultSize  OPTIONAL,
IN PCWCH  UnicodeString,
IN ULONG  UnicodeSize 
)

Definition at line 526 of file nls.c.

531{
532 ULONG Size = 0;
533 ULONG i;
534
536
537 if (!NlsMbCodePageTag)
538 {
539 /* single-byte code page */
540 Size = (UnicodeSize > (MbSize * sizeof(WCHAR)))
541 ? MbSize : (UnicodeSize / sizeof(WCHAR));
542
543 if (ResultSize)
544 *ResultSize = Size;
545
546 for (i = 0; i < Size; i++)
547 {
548 *MbString++ = NlsUnicodeToAnsiTable[*UnicodeString++];
549 }
550 }
551 else
552 {
553 /* multi-byte code page */
554 /* FIXME */
555
556 USHORT WideChar;
557 USHORT MbChar;
558
559 for (i = MbSize, Size = UnicodeSize / sizeof(WCHAR); i && Size; i--, Size--)
560 {
561 WideChar = *UnicodeString++;
562
563 if (WideChar < 0x80)
564 {
565 *MbString++ = LOBYTE(WideChar);
566 continue;
567 }
568
569 MbChar = NlsUnicodeToMbAnsiTable[WideChar];
570
571 if (!HIBYTE(MbChar))
572 {
573 *MbString++ = LOBYTE(MbChar);
574 continue;
575 }
576
577 if (i >= 2)
578 {
579 *MbString++ = HIBYTE(MbChar);
580 *MbString++ = LOBYTE(MbChar);
581 i--;
582 }
583 else break;
584 }
585
586 if (ResultSize)
587 *ResultSize = MbSize - i;
588 }
589
590 return STATUS_SUCCESS;
591}
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486

◆ RtlUnicodeToMultiByteSize()

NTSTATUS NTAPI RtlUnicodeToMultiByteSize ( OUT PULONG  MbSize,
IN PCWCH  UnicodeString,
IN ULONG  UnicodeSize 
)

Definition at line 598 of file nls.c.

601{
602 ULONG UnicodeLength = UnicodeSize / sizeof(WCHAR);
603 ULONG MbLength = 0;
604
606
607 if (!NlsMbCodePageTag)
608 {
609 /* single-byte code page */
610 *MbSize = UnicodeLength;
611 }
612 else
613 {
614 /* multi-byte code page */
615 /* FIXME */
616
617 while (UnicodeLength--)
618 {
619 USHORT WideChar = *UnicodeString++;
620
621 if (WideChar >= 0x80 && HIBYTE(NlsUnicodeToMbAnsiTable[WideChar]))
622 {
623 MbLength += sizeof(WCHAR);
624 }
625 else
626 {
627 MbLength++;
628 }
629 }
630
631 *MbSize = MbLength;
632 }
633
634 /* Success */
635 return STATUS_SUCCESS;
636}

◆ RtlUnicodeToOemN()

NTSTATUS NTAPI RtlUnicodeToOemN ( OUT PCHAR  OemString,
IN ULONG  OemSize,
OUT PULONG ResultSize  OPTIONAL,
IN PCWCH  UnicodeString,
IN ULONG  UnicodeSize 
)

Definition at line 643 of file nls.c.

648{
649 ULONG Size = 0;
650
652
653 /* Bytes -> chars */
654 UnicodeSize /= sizeof(WCHAR);
655
657 {
658 while (OemSize && UnicodeSize)
659 {
661 Size++;
662 OemSize--;
663 UnicodeSize--;
664 }
665 }
666 else
667 {
668 while (OemSize && UnicodeSize)
669 {
671
672 if (HIBYTE(OemChar))
673 {
674 if (OemSize < 2)
675 break;
676 OemString[Size++] = HIBYTE(OemChar);
677 OemSize--;
678 }
679 OemString[Size++] = LOBYTE(OemChar);
680 OemSize--;
681 UnicodeSize--;
682 }
683 }
684
685 if (ResultSize)
686 *ResultSize = Size;
687
688 return UnicodeSize ? STATUS_BUFFER_OVERFLOW : STATUS_SUCCESS;
689}
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66

◆ RtlUpcaseUnicodeChar()

WCHAR NTAPI RtlUpcaseUnicodeChar ( IN WCHAR  Source)

Definition at line 721 of file nls.c.

722{
724
726}
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:695

◆ RtlUpcaseUnicodeToCustomCPN()

NTSTATUS NTAPI RtlUpcaseUnicodeToCustomCPN ( IN PCPTABLEINFO  CustomCP,
OUT PCHAR  CustomString,
IN ULONG  CustomSize,
OUT PULONG ResultSize  OPTIONAL,
IN PWCHAR  UnicodeString,
IN ULONG  UnicodeSize 
)

Definition at line 732 of file nls.c.

738{
739 WCHAR UpcaseChar;
740 ULONG Size = 0;
741 ULONG i;
742
744
745 if (!CustomCP->DBCSCodePage)
746 {
747 /* single-byte code page */
748 if (UnicodeSize > (CustomSize * sizeof(WCHAR)))
749 Size = CustomSize;
750 else
751 Size = UnicodeSize / sizeof(WCHAR);
752
753 if (ResultSize)
754 *ResultSize = Size;
755
756 for (i = 0; i < Size; i++)
757 {
759 *CustomString = ((PCHAR)CustomCP->WideCharTable)[UpcaseChar];
760 ++CustomString;
762 }
763 }
764 else
765 {
766 /* multi-byte code page */
767 /* FIXME */
768 ASSERT(FALSE);
769 }
770
771 return STATUS_SUCCESS;
772}

◆ RtlUpcaseUnicodeToMultiByteN()

NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN ( OUT PCHAR  MbString,
IN ULONG  MbSize,
OUT PULONG ResultSize  OPTIONAL,
IN PCWCH  UnicodeString,
IN ULONG  UnicodeSize 
)

Definition at line 778 of file nls.c.

783{
784 WCHAR UpcaseChar;
785 ULONG Size = 0;
786 ULONG i;
787
789
790 if (!NlsMbCodePageTag)
791 {
792 /* single-byte code page */
793 if (UnicodeSize > (MbSize * sizeof(WCHAR)))
794 Size = MbSize;
795 else
796 Size = UnicodeSize / sizeof(WCHAR);
797
798 if (ResultSize)
799 *ResultSize = Size;
800
801 for (i = 0; i < Size; i++)
802 {
804 *MbString = NlsUnicodeToAnsiTable[UpcaseChar];
805 MbString++;
807 }
808 }
809 else
810 {
811 /* multi-byte code page */
812 /* FIXME */
813 ASSERT(FALSE);
814 }
815
816 return STATUS_SUCCESS;
817}

◆ RtlUpcaseUnicodeToOemN()

NTSTATUS NTAPI RtlUpcaseUnicodeToOemN ( OUT PCHAR  OemString,
IN ULONG  OemSize,
OUT PULONG ResultSize  OPTIONAL,
IN PCWCH  UnicodeString,
IN ULONG  UnicodeSize 
)

Definition at line 823 of file nls.c.

828{
829 WCHAR UpcaseChar;
830 ULONG Size = 0;
831 ULONG i;
832
834
836 {
837 /* single-byte code page */
838 if (UnicodeSize > (OemSize * sizeof(WCHAR)))
839 Size = OemSize;
840 else
841 Size = UnicodeSize / sizeof(WCHAR);
842
843 if (ResultSize)
844 *ResultSize = Size;
845
846 for (i = 0; i < Size; i++)
847 {
849 *OemString = NlsUnicodeToOemTable[UpcaseChar];
850 OemString++;
852 }
853 }
854 else
855 {
856 /* multi-byte code page */
857 /* FIXME */
858
859 USHORT WideChar;
860 USHORT OemChar;
861
862 for (i = OemSize, Size = UnicodeSize / sizeof(WCHAR); i && Size; i--, Size--)
863 {
865
866 if (WideChar < 0x80)
867 {
868 *OemString++ = LOBYTE(WideChar);
869 continue;
870 }
871
872 OemChar = NlsUnicodeToMbOemTable[WideChar];
873
874 if (!HIBYTE(OemChar))
875 {
876 *OemString++ = LOBYTE(OemChar);
877 continue;
878 }
879
880 if (i >= 2)
881 {
882 *OemString++ = HIBYTE(OemChar);
883 *OemString++ = LOBYTE(OemChar);
884 i--;
885 }
886 else break;
887 }
888
889 if (ResultSize)
890 *ResultSize = OemSize - i;
891 }
892
893 return STATUS_SUCCESS;
894}

◆ RtlUpperChar()

CHAR NTAPI RtlUpperChar ( IN CHAR  Source)

Definition at line 900 of file nls.c.

901{
902 WCHAR Unicode;
904
906
907 /* Check for simple ANSI case */
908 if (Source <= 'z')
909 {
910 /* Check for simple downcase a-z case */
911 if (Source >= 'a')
912 {
913 /* Just XOR with the difference */
914 return Source ^ ('a' - 'A');
915 }
916 else
917 {
918 /* Otherwise return the same char, it's already upcase */
919 return Source;
920 }
921 }
922 else
923 {
924 if (!NlsMbCodePageTag)
925 {
926 /* single-byte code page */
927
928 /* ansi->unicode */
930
931 /* upcase conversion */
932 Unicode = RtlpUpcaseUnicodeChar (Unicode);
933
934 /* unicode -> ansi */
936 }
937 else
938 {
939 /* multi-byte code page */
940 /* FIXME */
942 }
943 }
944
945 return Destination;
946}
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3004
char CHAR
Definition: xmlstorage.h:175

Variable Documentation

◆ NlsAnsiCodePage

USHORT NlsAnsiCodePage = 0

Definition at line 21 of file nls.c.

Referenced by RtlGetDefaultCodePage(), and RtlResetRtlTranslations().

◆ NlsAnsiToUnicodeTable

PUSHORT NlsAnsiToUnicodeTable = NULL

Definition at line 23 of file nls.c.

Referenced by RtlMultiByteToUnicodeN(), RtlResetRtlTranslations(), and RtlUpperChar().

◆ NlsLeadByteInfo

◆ NlsMbCodePageTag

◆ NlsMbOemCodePageTag

◆ NlsOemCodePage

USHORT NlsOemCodePage = 0

Definition at line 28 of file nls.c.

Referenced by RtlGetDefaultCodePage(), and RtlResetRtlTranslations().

◆ NlsOemDefaultChar

USHORT NlsOemDefaultChar = '\0'

Definition at line 35 of file nls.c.

Referenced by RtlIsValidOemCharacter(), RtlpDidUnicodeToOemWork(), and RtlResetRtlTranslations().

◆ NlsOemLeadByteInfo

PUSHORT NlsOemLeadByteInfo = NULL

Definition at line 33 of file nls.c.

Referenced by RtlIsValidOemCharacter(), RtlOemToUnicodeN(), and RtlResetRtlTranslations().

◆ NlsOemToUnicodeTable

PUSHORT NlsOemToUnicodeTable = NULL

Definition at line 30 of file nls.c.

Referenced by RtlIsValidOemCharacter(), RtlOemToUnicodeN(), and RtlResetRtlTranslations().

◆ NlsUnicodeDefaultChar

USHORT NlsUnicodeDefaultChar = 0

Definition at line 36 of file nls.c.

Referenced by RtlpDidUnicodeToOemWork(), and RtlResetRtlTranslations().

◆ NlsUnicodeLowercaseTable

PUSHORT NlsUnicodeLowercaseTable = NULL

Definition at line 19 of file nls.c.

Referenced by RtlpDowncaseUnicodeChar(), and RtlResetRtlTranslations().

◆ NlsUnicodeToAnsiTable

PCHAR NlsUnicodeToAnsiTable = NULL

◆ NlsUnicodeToMbAnsiTable

PUSHORT NlsUnicodeToMbAnsiTable = NULL

◆ NlsUnicodeToMbOemTable

◆ NlsUnicodeToOemTable

PCHAR NlsUnicodeToOemTable = NULL

◆ NlsUnicodeUpcaseTable

PUSHORT NlsUnicodeUpcaseTable = NULL

Definition at line 18 of file nls.c.

Referenced by RtlpUpcaseUnicodeChar(), and RtlResetRtlTranslations().