Use NLS-Section in user-mode.

svn path=/trunk/; revision=4736
This commit is contained in:
Eric Kohl 2003-05-21 16:11:02 +00:00
parent 17ad474bcb
commit faa8f94f27
3 changed files with 482 additions and 444 deletions

View file

@ -1,4 +1,4 @@
/* $Id: startup.c,v 1.51 2003/05/12 19:47:53 ekohl Exp $
/* $Id: startup.c,v 1.52 2003/05/21 16:10:12 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -55,6 +55,7 @@ __true_LdrInitializeThunk (ULONG Unknown1,
PPEB Peb;
PLDR_MODULE NtModule; // ntdll
PLDR_MODULE ExeModule; // executable
NLSTABLEINFO NlsTable;
WCHAR FullNtDllPath[MAX_PATH];
DPRINT("LdrInitializeThunk()\n");
@ -94,11 +95,6 @@ __true_LdrInitializeThunk (ULONG Unknown1,
ZwTerminateProcess(NtCurrentProcess(), STATUS_UNSUCCESSFUL);
}
Peb->OSMajorVersion = 4;
Peb->OSMinorVersion = 0;
Peb->OSBuildNumber = 0;
Peb->OSPlatformId = VER_PLATFORM_WIN32_NT;
NtGlobalFlag = Peb->NtGlobalFlag;
/* If MZ header exists */
@ -115,14 +111,12 @@ __true_LdrInitializeThunk (ULONG Unknown1,
/* normalize process parameters */
RtlNormalizeProcessParams (Peb->ProcessParameters);
#if 0
/* initialize NLS data */
/* Initialize NLS data */
RtlInitNlsTables (Peb->AnsiCodePageData,
Peb->OemCodePageData,
Peb->UnicodeCaseTableData,
&TranslationTable);
RtlResetRtlTranslations (&TranslationTable);
#endif
&NlsTable);
RtlResetRtlTranslations (&NlsTable);
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew);

View file

@ -1,4 +1,4 @@
/* $Id: nls.c,v 1.9 2003/05/16 17:34:25 ekohl Exp $
/* $Id: nls.c,v 1.10 2003/05/21 16:11:02 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -8,17 +8,8 @@
* 20/08/99 Created by Emanuele Aliberti
* 10/11/99 Added translation functions.
*
* NOTE:
* Multi-byte code pages are not supported yet. Even single-byte code
* pages are not supported properly. Only stupid CHAR->WCHAR and
* WCHAR->CHAR (Attention: data loss!!!) translation is done.
*
* TODO:
* 1) Implement code to initialize the translation tables.
* 2) Use fixed translation table for translation.
* 3) Add loading of translation tables (NLS files).
* 4) Implement unicode upcase and downcase handling.
* 5) Add multi-byte translation code.
* 1) Add multi-byte translation code.
*/
#include <ddk/ntddk.h>
@ -27,34 +18,27 @@
#include <debug.h>
BOOLEAN
NlsMbCodePageTag = FALSE;
/* GLOBALS *******************************************************************/
BOOLEAN
NlsMbOemCodePageTag = FALSE;
BYTE NlsLeadByteInfo = 0; /* ? */
BYTE
NlsLeadByteInfo = 0; /* ? */
USHORT NlsOemLeadByteInfo = 0;
USHORT
NlsOemLeadByteInfo = 0;
USHORT
NlsAnsiCodePage = 0;
USHORT
NlsOemCodePage = 0; /* not exported */
#if 0
USHORT NlsAnsiCodePage = 0; /* exported */
BOOLEAN NlsMbCodePageTag = FALSE; /* exported */
PWCHAR NlsAnsiToUnicodeTable = NULL;
PWCHAR NlsOemToUnicodeTable = NULL;
PCHAR NlsUnicodeToAnsiTable = NULL;
USHORT NlsOemCodePage = 0;
BOOLEAN NlsMbOemCodePageTag = FALSE; /* exported */
PWCHAR NlsOemToUnicodeTable = NULL;
PCHAR NlsUnicodeToOemTable = NULL;
PWCHAR NlsUnicodeUpcaseTable = NULL;
PWCHAR NlsUnicodeLowercaseTable = NULL;
#endif
PUSHORT NlsUnicodeUpcaseTable = NULL;
PUSHORT NlsUnicodeLowercaseTable = NULL;
/* FUNCTIONS *****************************************************************/
@ -64,8 +48,7 @@ PWCHAR NlsUnicodeLowercaseTable = NULL;
*/
NTSTATUS
STDCALL
NTSTATUS STDCALL
RtlCustomCPToUnicodeN(IN PCPTABLEINFO CustomCP,
PWCHAR UnicodeString,
ULONG UnicodeSize,
@ -105,9 +88,47 @@ RtlCustomCPToUnicodeN(IN PCPTABLEINFO CustomCP,
}
WCHAR
RtlDowncaseUnicodeChar (IN WCHAR Source)
{
USHORT Offset;
if (Source < L'A')
return Source;
if (Source <= L'Z')
return Source + (L'a' - L'A');
if (Source < 0x80)
return Source;
Offset = ((USHORT)Source >> 8);
DPRINT("Offset: %hx\n", Offset);
Offset = NlsUnicodeLowercaseTable[Offset];
DPRINT("Offset: %hx\n", Offset);
Offset += (((USHORT)Source & 0x00F0) >> 4);
DPRINT("Offset: %hx\n", Offset);
Offset = NlsUnicodeLowercaseTable[Offset];
DPRINT("Offset: %hx\n", Offset);
Offset += ((USHORT)Source & 0x000F);
DPRINT("Offset: %hx\n", Offset);
Offset = NlsUnicodeLowercaseTable[Offset];
DPRINT("Offset: %hx\n", Offset);
DPRINT("Result: %hx\n", Source + (SHORT)Offset);
return Source + (SHORT)Offset;
}
VOID STDCALL
RtlGetDefaultCodePage(PUSHORT AnsiCodePage,
PUSHORT OemCodePage)
RtlGetDefaultCodePage(OUT PUSHORT AnsiCodePage,
OUT PUSHORT OemCodePage)
{
*AnsiCodePage = NlsAnsiCodePage;
*OemCodePage = NlsOemCodePage;
@ -118,7 +139,54 @@ VOID STDCALL
RtlInitCodePageTable(IN PUSHORT TableBase,
OUT PCPTABLEINFO CodePageTable)
{
UNIMPLEMENTED;
PNLS_FILE_HEADER NlsFileHeader;
PUSHORT Ptr;
USHORT Offset;
DPRINT("RtlInitCodePageTable() called\n");
NlsFileHeader = (PNLS_FILE_HEADER)TableBase;
CodePageTable->CodePage = NlsFileHeader->CodePage;
CodePageTable->MaximumCharacterSize = NlsFileHeader->MaximumCharacterSize;
CodePageTable->DefaultChar = NlsFileHeader->DefaultChar;
CodePageTable->UniDefaultChar = NlsFileHeader->UniDefaultChar;
CodePageTable->TransDefaultChar = NlsFileHeader->TransDefaultChar;
CodePageTable->TransUniDefaultChar = NlsFileHeader->TransUniDefaultChar;
RtlCopyMemory(&CodePageTable->LeadByte,
&NlsFileHeader->LeadByte,
MAXIMUM_LEADBYTES);
/* Set Pointer to start of multi byte table */
Ptr = (PUSHORT)((ULONG_PTR)TableBase + 2 * NlsFileHeader->HeaderSize);
/* Get offset to the wide char table */
Offset = (USHORT)(*Ptr++) + NlsFileHeader->HeaderSize + 1;
/* Set pointer to the multi byte table */
CodePageTable->MultiByteTable = Ptr;
/* Skip ANSI and OEM table */
Ptr += 256;
if (*Ptr++)
Ptr += 256;
/* Set pointer to DBCS ranges */
CodePageTable->DBCSRanges = (PUSHORT)Ptr;
if (*Ptr > 0)
{
CodePageTable->DBCSCodePage = 1;
CodePageTable->DBCSOffsets = (PUSHORT)++Ptr;
}
else
{
CodePageTable->DBCSCodePage = 0;
CodePageTable->DBCSOffsets = 0;
}
CodePageTable->WideCharTable = (PVOID)((ULONG_PTR)TableBase + 2 * Offset);
}
@ -128,130 +196,145 @@ RtlInitNlsTables(IN PUSHORT AnsiTableBase,
IN PUSHORT CaseTableBase,
OUT PNLSTABLEINFO NlsTable)
{
UNIMPLEMENTED;
DPRINT("RtlInitNlsTables()called\n");
if (AnsiTableBase == NULL ||
OemTableBase == NULL ||
CaseTableBase == NULL)
return;
RtlInitCodePageTable (AnsiTableBase,
&NlsTable->AnsiTableInfo);
RtlInitCodePageTable (OemTableBase,
&NlsTable->OemTableInfo);
NlsTable->UpperCaseTable = (PUSHORT)CaseTableBase + 2;
NlsTable->LowerCaseTable = (PUSHORT)CaseTableBase + *((PUSHORT)CaseTableBase + 1) + 2;
}
NTSTATUS
STDCALL
RtlMultiByteToUnicodeN (
PWCHAR UnicodeString,
ULONG UnicodeSize,
PULONG ResultSize,
PCHAR MbString,
ULONG MbSize
)
NTSTATUS STDCALL
RtlMultiByteToUnicodeN (IN OUT PWCHAR UnicodeString,
IN ULONG UnicodeSize,
OUT PULONG ResultSize,
IN PCHAR MbString,
IN ULONG MbSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
if (NlsMbCodePageTag == FALSE)
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
if (MbSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = MbSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (MbSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = MbSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
*UnicodeString = *MbString;
#if 0
*UnicodeString = NlsAnsiToUnicodeTable[*MbString];
#endif
UnicodeString++;
MbString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
*UnicodeString = NlsAnsiToUnicodeTable[*MbString];
UnicodeString++;
MbString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
}
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
RtlMultiByteToUnicodeSize (
PULONG UnicodeSize,
PCHAR MbString,
ULONG MbSize
)
NTSTATUS STDCALL
RtlMultiByteToUnicodeSize (OUT PULONG UnicodeSize,
IN PCHAR MbString,
IN ULONG MbSize)
{
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*UnicodeSize = MbSize * sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*UnicodeSize = MbSize * sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
RtlOemToUnicodeN (
PWCHAR UnicodeString,
ULONG UnicodeSize,
PULONG ResultSize,
PCHAR OemString,
ULONG OemSize
)
NTSTATUS STDCALL
RtlOemToUnicodeN (PWCHAR UnicodeString,
ULONG UnicodeSize,
PULONG ResultSize,
PCHAR OemString,
ULONG OemSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
if (NlsMbOemCodePageTag == FALSE)
if (NlsMbOemCodePageTag == FALSE)
{
/* single-byte code page */
if (OemSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = OemSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (OemSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = OemSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
*UnicodeString = *OemString;
#if 0
*UnicodeString = NlsOemToUnicodeTable[*OemString];
#endif
UnicodeString++;
OemString++;
};
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
*UnicodeString = NlsOemToUnicodeTable[*OemString];
UnicodeString++;
OemString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
}
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
VOID STDCALL
RtlResetRtlTranslations(IN PNLSTABLEINFO NlsTable)
{
UNIMPLEMENTED;
DPRINT("RtlResetRtlTranslations() called\n");
/* Set ANSI data */
NlsAnsiToUnicodeTable = NlsTable->AnsiTableInfo.MultiByteTable;
NlsUnicodeToAnsiTable = NlsTable->AnsiTableInfo.WideCharTable;
NlsMbCodePageTag = (NlsTable->AnsiTableInfo.DBCSCodePage != 0);
NlsAnsiCodePage = NlsTable->AnsiTableInfo.CodePage;
DPRINT("Ansi codepage %hu\n", NlsAnsiCodePage);
/* Set OEM data */
NlsOemToUnicodeTable = NlsTable->OemTableInfo.MultiByteTable;
NlsUnicodeToOemTable = NlsTable->OemTableInfo.WideCharTable;
NlsMbOemCodePageTag = (NlsTable->OemTableInfo.DBCSCodePage != 0);
NlsOemCodePage = NlsTable->OemTableInfo.CodePage;
DPRINT("Oem codepage %hu\n", NlsOemCodePage);
/* Set Unicode case map data */
NlsUnicodeUpcaseTable = NlsTable->UpperCaseTable;
NlsUnicodeLowercaseTable = NlsTable->LowerCaseTable;
}
@ -295,130 +378,137 @@ RtlUnicodeToCustomCPN(IN PCPTABLEINFO CustomCP,
}
NTSTATUS
STDCALL
RtlUnicodeToMultiByteN (
PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
)
NTSTATUS STDCALL
RtlUnicodeToMultiByteN (PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
if (NlsMbCodePageTag == FALSE)
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*MbString = *UnicodeString;
#if 0
*MbString = UnicodeToAnsiTable[*UnicodeString];
#endif
MbString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
*MbString = NlsUnicodeToAnsiTable[*UnicodeString];
MbString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
}
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
RtlUnicodeToMultiByteSize (
PULONG MbSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
)
{
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*MbSize = UnicodeSize / sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
*MbSize = 0;
assert(FALSE);
}
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
RtlUnicodeToOemN (
PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
)
{
ULONG Size = 0;
ULONG i;
if (NlsMbOemCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*OemString = *UnicodeString;
#if 0
*OemString = UnicodeToOemTable[*UnicodeString];
#endif
OemString++;
UnicodeString++;
};
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
}
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
NTSTATUS STDCALL
RtlUpcaseUnicodeToCustomCPN(IN PCPTABLEINFO CustomCP,
PCHAR CustomString,
ULONG CustomSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
RtlUnicodeToMultiByteSize (PULONG MbSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*MbSize = UnicodeSize / sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
*MbSize = 0;
assert(FALSE);
}
return STATUS_SUCCESS;
}
NTSTATUS STDCALL
RtlUnicodeToOemN (PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
if (NlsMbOemCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*OemString = NlsUnicodeToOemTable[*UnicodeString];
OemString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
}
return STATUS_SUCCESS;
}
WCHAR STDCALL
RtlUpcaseUnicodeChar(IN WCHAR Source)
{
USHORT Offset;
if (Source < L'a')
return Source;
if (Source <= L'z')
return (Source - (L'a' - L'A'));
Offset = ((USHORT)Source >> 8);
Offset = NlsUnicodeUpcaseTable[Offset];
Offset += (((USHORT)Source & 0x00F0) >> 4);
Offset = NlsUnicodeUpcaseTable[Offset];
Offset += ((USHORT)Source & 0x000F);
Offset = NlsUnicodeUpcaseTable[Offset];
return Source + (SHORT)Offset;
}
NTSTATUS STDCALL
RtlUpcaseUnicodeToCustomCPN (IN PCPTABLEINFO CustomCP,
PCHAR CustomString,
ULONG CustomSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
WCHAR UpcaseChar;
ULONG Size = 0;
@ -437,11 +527,8 @@ RtlUpcaseUnicodeToCustomCPN(IN PCPTABLEINFO CustomCP,
for (i = 0; i < Size; i++)
{
*CustomString = ((PCHAR)CustomCP->WideCharTable)[*UnicodeString];
#if 0
UpcaseChar = NlsUnicodeUpcaseTable[*UnicodeString];
*CustomString = NlsData->UnicodeToMultiByte[UpcaseChar];
#endif
UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString);
*CustomString = ((PCHAR)CustomCP->WideCharTable)[UpcaseChar];
CustomString++;
UnicodeString++;
}
@ -457,99 +544,115 @@ RtlUpcaseUnicodeToCustomCPN(IN PCPTABLEINFO CustomCP,
}
NTSTATUS
STDCALL
RtlUpcaseUnicodeToMultiByteN (
PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
)
NTSTATUS STDCALL
RtlUpcaseUnicodeToMultiByteN (PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
WCHAR UpcaseChar;
ULONG Size = 0;
ULONG i;
WCHAR UpcaseChar;
ULONG Size = 0;
ULONG i;
if (NLS_MB_CODE_PAGE_TAG == FALSE)
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*MbString = *UnicodeString;
#if 0
UpcaseChar = NlsUnicodeUpcaseTable[*UnicodeString];
*MbString = NlsUnicodeToAnsiTable[UpcaseChar];
#endif
MbString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString);
*MbString = NlsUnicodeToAnsiTable[UpcaseChar];
MbString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
}
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
RtlUpcaseUnicodeToOemN (
PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
)
NTSTATUS STDCALL
RtlUpcaseUnicodeToOemN (PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
WCHAR UpcaseChar;
ULONG Size = 0;
ULONG i;
WCHAR UpcaseChar;
ULONG Size = 0;
ULONG i;
if (NLS_MB_OEM_CODE_PAGE_TAG == FALSE)
if (NlsMbOemCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*OemString = *UnicodeString;
#if 0
UpcaseChar = NlsUnicodeUpcaseTable[*UnicodeString];
*OemString = UnicodeToOemTable[UpcaseChar];
#endif
OemString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString);
*OemString = NlsUnicodeToOemTable[UpcaseChar];
OemString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
assert(FALSE);
}
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
CHAR STDCALL
RtlUpperChar (IN CHAR Source)
{
WCHAR Unicode;
CHAR Destination;
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
/* ansi->unicode */
Unicode = NlsAnsiToUnicodeTable[Source];
/* upcase conversion */
Unicode = RtlUpcaseUnicodeChar (Unicode);
/* unicode -> ansi */
Destination = NlsUnicodeToAnsiTable[Unicode];
}
else
{
/* single-byte code page */
/* FIXME: implement the multi-byte stuff!! */
Destination = Source;
}
return Destination;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: unicode.c,v 1.26 2003/03/26 15:16:50 ekohl Exp $
/* $Id: unicode.c,v 1.27 2003/05/21 16:11:02 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -17,43 +17,45 @@
#define NDEBUG
#include <ntdll/ntdll.h>
extern PUSHORT NlsUnicodeUpcaseTable;
extern PUSHORT NlsUnicodeLowercaseTable;
WCHAR RtlDowncaseUnicodeChar(IN WCHAR Source);
/* FUNCTIONS *****************************************************************/
WCHAR
STDCALL
RtlAnsiCharToUnicodeChar(
IN CHAR AnsiChar)
WCHAR STDCALL
RtlAnsiCharToUnicodeChar (IN CHAR AnsiChar)
{
ULONG Size;
WCHAR UnicodeChar;
ULONG Size;
WCHAR UnicodeChar;
Size = 1;
Size = 1;
#if 0
Size = (NlsLeadByteInfo[AnsiChar] == 0) ? 1 : 2;
Size = (NlsLeadByteInfo[AnsiChar] == 0) ? 1 : 2;
#endif
RtlMultiByteToUnicodeN (&UnicodeChar,
sizeof(WCHAR),
NULL,
&AnsiChar,
Size);
RtlMultiByteToUnicodeN (&UnicodeChar,
sizeof(WCHAR),
NULL,
&AnsiChar,
Size);
return UnicodeChar;
return UnicodeChar;
}
ULONG
STDCALL
RtlAnsiStringToUnicodeSize(
IN PANSI_STRING AnsiString)
ULONG STDCALL
RtlAnsiStringToUnicodeSize (IN PANSI_STRING AnsiString)
{
ULONG Size;
ULONG Size;
RtlMultiByteToUnicodeSize (&Size,
AnsiString->Buffer,
AnsiString->Length);
RtlMultiByteToUnicodeSize (&Size,
AnsiString->Buffer,
AnsiString->Length);
return Size;
return Size;
}
@ -520,8 +522,7 @@ RtlDowncaseUnicodeString(
}
else
{
/* FIXME: characters above 'Z' */
*Dest = *Src;
*Dest = RtlDowncaseUnicodeChar(*Src);
}
Dest++;
@ -1446,22 +1447,6 @@ RtlUnicodeStringToOemString(
}
WCHAR
STDCALL
RtlUpcaseUnicodeChar(IN WCHAR Source)
{
if (Source < L'a')
return Source;
if (Source <= L'z')
return (Source - (L'a' - L'A'));
/* FIXME: characters above 'z' */
return Source;
}
NTSTATUS
STDCALL
RtlUpcaseUnicodeString(
@ -1701,49 +1686,9 @@ RtlUpcaseUnicodeStringToOemString (
}
CHAR
STDCALL
RtlUpperChar (
IN CHAR Source
)
{
WCHAR Unicode;
CHAR Destination;
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
/* ansi->unicode */
Unicode = (WCHAR)Source;
#if 0
Unicode = NlsAnsiToUnicodeData[Source];
#endif
/* upcase conversion */
Unicode = RtlUpcaseUnicodeChar (Unicode);
/* unicode -> ansi */
Destination = (CHAR)Unicode;
#if 0
Destination = NlsUnicodeToAnsiData[Unicode];
#endif
}
else
{
/* single-byte code page */
/* FIXME: implement the multi-byte stuff!! */
Destination = Source;
}
return Destination;
}
VOID
STDCALL
RtlUpperString(
IN OUT PSTRING DestinationString,
IN PSTRING SourceString)
VOID STDCALL
RtlUpperString (IN OUT PSTRING DestinationString,
IN PSTRING SourceString)
{
ULONG Length;
ULONG i;
@ -1766,35 +1711,31 @@ RtlUpperString(
}
ULONG
STDCALL
RtlxAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
ULONG STDCALL
RtlxAnsiStringToUnicodeSize (IN PANSI_STRING AnsiString)
{
return RtlAnsiStringToUnicodeSize(AnsiString);
return RtlAnsiStringToUnicodeSize (AnsiString);
}
ULONG
STDCALL
RtlxOemStringToUnicodeSize(IN POEM_STRING OemString)
ULONG STDCALL
RtlxOemStringToUnicodeSize (IN POEM_STRING OemString)
{
return RtlAnsiStringToUnicodeSize((PANSI_STRING)OemString);
return RtlAnsiStringToUnicodeSize ((PANSI_STRING)OemString);
}
ULONG
STDCALL
RtlxUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
ULONG STDCALL
RtlxUnicodeStringToAnsiSize (IN PUNICODE_STRING UnicodeString)
{
return RtlUnicodeStringToAnsiSize(UnicodeString);
return RtlUnicodeStringToAnsiSize (UnicodeString);
}
ULONG
STDCALL
RtlxUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
ULONG STDCALL
RtlxUnicodeStringToOemSize (IN PUNICODE_STRING UnicodeString)
{
return RtlUnicodeStringToAnsiSize(UnicodeString);
return RtlUnicodeStringToAnsiSize (UnicodeString);
}
/* EOF */