update for HEAD-2003091401
[reactos.git] / lib / ntdll / rtl / unicode.c
index 7278792..c5d10e5 100644 (file)
 #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)
+/*
+ * @implemented
+ */
+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;
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlAnsiStringToUnicodeString(
@@ -120,6 +128,9 @@ RtlAnsiStringToUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlAppendAsciizToString(
@@ -149,6 +160,9 @@ RtlAppendAsciizToString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlAppendStringToString(
@@ -176,42 +190,34 @@ RtlAppendStringToString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlAppendUnicodeStringToString(
        IN OUT  PUNICODE_STRING Destination,
        IN      PUNICODE_STRING Source)
 {
-       PWCHAR Src;
-       PWCHAR Dest;
-       ULONG  i;
 
        if ((Source->Length + Destination->Length) >= Destination->MaximumLength)
                return STATUS_BUFFER_TOO_SMALL;
 
-       Src  = Source->Buffer;
-       Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR));
-       for (i = 0; i < (Source->Length / sizeof(WCHAR)); i++)
-       {
-               *Dest = *Src;
-               Dest++;
-               Src++;
-       }
-       *Dest = 0;
-
-       Destination->Length += Source->Length;
+       memcpy((PVOID)Destination->Buffer + Destination->Length, Source->Buffer, Source->Length);
+        Destination->Length += Source->Length;
+       Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0;
 
        return STATUS_SUCCESS;
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
                         IN PWSTR Source)
 {
-  PWCHAR Src;
-  PWCHAR Dest;
-  ULONG i;
   ULONG slen;
 
   slen = wcslen(Source) * sizeof(WCHAR);
@@ -219,23 +225,17 @@ RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
   if (Destination->Length + slen >= Destination->MaximumLength)
     return(STATUS_BUFFER_TOO_SMALL);
 
-  Src = Source;
-  Dest = Destination->Buffer + (Destination->Length / sizeof(WCHAR));
-
-  for (i = 0; i < (slen / sizeof(WCHAR)); i++)
-    {
-      *Dest = *Src;
-      Dest++;
-      Src++;
-    }
-  *Dest = 0;
-
+  memcpy((PVOID)Destination->Buffer + Destination->Length, Source, slen);
   Destination->Length += slen;
+  Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0;
 
   return(STATUS_SUCCESS);
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlCharToInteger(
@@ -277,6 +277,9 @@ RtlCharToInteger(
 }
 
 
+/*
+ * @implemented
+ */
 LONG
 STDCALL
 RtlCompareString(
@@ -324,6 +327,9 @@ RtlCompareString(
 }
 
 
+/*
+ * @implemented
+ */
 LONG
 STDCALL
 RtlCompareUnicodeString(
@@ -371,14 +377,16 @@ RtlCompareUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlCopyString(
        IN OUT  PSTRING DestinationString,
        IN      PSTRING SourceString)
 {
-       ULONG copylen, i;
-       PCHAR Src, Dest;
+       ULONG copylen;
 
        if (SourceString == NULL)
        {
@@ -388,29 +396,22 @@ RtlCopyString(
 
        copylen = min (DestinationString->MaximumLength - sizeof(CHAR),
                       SourceString->Length);
-       Src = SourceString->Buffer;
-       Dest = DestinationString->Buffer;
-
-       for (i = 0; i < copylen; i++)
-       {
-               *Dest = *Src;
-               Dest++;
-               Src++;
-       }
-       *Dest = 0;
-
+       memcpy(DestinationString->Buffer, SourceString->Buffer, copylen);
        DestinationString->Length = copylen;
+       DestinationString->Buffer[copylen] = 0;
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlCopyUnicodeString(
        IN OUT  PUNICODE_STRING DestinationString,
        IN      PUNICODE_STRING SourceString)
 {
-       ULONG copylen, i;
-       PWCHAR Src, Dest;
+       ULONG copylen;
 
        if (SourceString == NULL)
        {
@@ -420,21 +421,15 @@ RtlCopyUnicodeString(
 
        copylen = min (DestinationString->MaximumLength - sizeof(WCHAR),
                       SourceString->Length);
-       Src = SourceString->Buffer;
-       Dest = DestinationString->Buffer;
-
-       for (i = 0; i < (copylen / sizeof (WCHAR)); i++)
-       {
-               *Dest = *Src;
-               Dest++;
-               Src++;
-       }
-       *Dest = 0;
-
+       memcpy(DestinationString->Buffer, SourceString->Buffer, copylen);
+       DestinationString->Buffer[copylen / sizeof(WCHAR)] = 0;
        DestinationString->Length = copylen;
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlCreateUnicodeString(
@@ -462,6 +457,9 @@ RtlCreateUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlCreateUnicodeStringFromAsciiz(
@@ -482,6 +480,9 @@ RtlCreateUnicodeStringFromAsciiz(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlDowncaseUnicodeString(
@@ -520,8 +521,7 @@ RtlDowncaseUnicodeString(
                }
                else
                {
-                       /* FIXME: characters above 'Z' */
-                       *Dest = *Src;
+                       *Dest = RtlDowncaseUnicodeChar(*Src);
                }
 
                Dest++;
@@ -533,6 +533,9 @@ RtlDowncaseUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlEqualComputerName(
@@ -544,6 +547,9 @@ RtlEqualComputerName(
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlEqualDomainName (
@@ -573,6 +579,9 @@ RtlEqualDomainName (
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlEqualString(
@@ -613,6 +622,9 @@ RtlEqualString(
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlEqualUnicodeString(
@@ -654,6 +666,9 @@ RtlEqualUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlEraseUnicodeString(
@@ -673,6 +688,9 @@ RtlEraseUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlFreeAnsiString(
@@ -691,6 +709,9 @@ RtlFreeAnsiString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlFreeOemString(
@@ -709,6 +730,9 @@ RtlFreeOemString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlFreeUnicodeString(
@@ -727,6 +751,9 @@ RtlFreeUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlInitAnsiString(
@@ -750,6 +777,9 @@ RtlInitAnsiString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlInitString(
@@ -773,6 +803,9 @@ RtlInitString(
 }
 
 
+/*
+ * @implemented
+ */
 VOID
 STDCALL
 RtlInitUnicodeString(
@@ -796,6 +829,9 @@ RtlInitUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlIntegerToChar(
@@ -843,6 +879,9 @@ RtlIntegerToChar(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlIntegerToUnicodeString(
@@ -875,6 +914,9 @@ RtlIntegerToUnicodeString(
 
 #define ITU_IMPLEMENTED_TESTS (IS_TEXT_UNICODE_ODD_LENGTH|IS_TEXT_UNICODE_SIGNATURE)
 
+/*
+ * @implemented
+ */
 ULONG STDCALL
 RtlIsTextUnicode (PVOID Buffer,
                  ULONG Length,
@@ -928,6 +970,9 @@ done:
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlLargeIntegerToChar(
@@ -975,6 +1020,9 @@ RtlLargeIntegerToChar(
 }
 
 
+/*
+ * @implemented
+ */
 ULONG
 STDCALL
 RtlOemStringToUnicodeSize(
@@ -990,6 +1038,9 @@ RtlOemStringToUnicodeSize(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlOemStringToUnicodeString(
@@ -1053,6 +1104,9 @@ RtlOemStringToUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlPrefixString(
@@ -1095,6 +1149,9 @@ RtlPrefixString(
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN
 STDCALL
 RtlPrefixUnicodeString(
@@ -1138,6 +1195,9 @@ RtlPrefixUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 ULONG
 STDCALL
 RtlUnicodeStringToAnsiSize(
@@ -1153,6 +1213,9 @@ RtlUnicodeStringToAnsiSize(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUnicodeStringToAnsiString(
@@ -1210,6 +1273,9 @@ RtlUnicodeStringToAnsiString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUnicodeStringToInteger(
@@ -1299,6 +1365,9 @@ RtlUnicodeStringToInteger(
 }
 
 
+/*
+ * @implemented
+ */
 ULONG
 STDCALL
 RtlUnicodeStringToOemSize(
@@ -1314,6 +1383,9 @@ RtlUnicodeStringToOemSize(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUnicodeStringToCountedOemString(
@@ -1380,6 +1452,9 @@ RtlUnicodeStringToCountedOemString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUnicodeStringToOemString(
@@ -1446,27 +1521,14 @@ 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;
-}
-
-
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUpcaseUnicodeString(
        IN OUT  PUNICODE_STRING DestinationString,
-       IN      PUNICODE_STRING SourceString,
+       IN      PCUNICODE_STRING        SourceString,
        IN      BOOLEAN         AllocateDestinationString)
 {
        ULONG i;
@@ -1502,6 +1564,9 @@ RtlUpcaseUnicodeString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUpcaseUnicodeStringToAnsiString(
@@ -1568,6 +1633,9 @@ RtlUpcaseUnicodeStringToAnsiString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUpcaseUnicodeStringToCountedOemString(
@@ -1634,6 +1702,9 @@ RtlUpcaseUnicodeStringToCountedOemString(
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlUpcaseUnicodeStringToOemString (
@@ -1701,49 +1772,12 @@ 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)
+/*
+ * @implemented
+ */
+VOID STDCALL
+RtlUpperString (IN OUT PSTRING DestinationString,
+               IN PSTRING SourceString)
 {
        ULONG Length;
        ULONG i;
@@ -1766,35 +1800,43 @@ RtlUpperString(
 }
 
 
-ULONG
-STDCALL
-RtlxAnsiStringToUnicodeSize(IN PANSI_STRING    AnsiString)
+/*
+ * @implemented
+ */
+ULONG STDCALL
+RtlxAnsiStringToUnicodeSize (IN PANSI_STRING AnsiString)
 {
-       return RtlAnsiStringToUnicodeSize(AnsiString);
+  return RtlAnsiStringToUnicodeSize (AnsiString);
 }
 
 
-ULONG
-STDCALL
-RtlxOemStringToUnicodeSize(IN  POEM_STRING     OemString)
+/*
+ * @implemented
+ */
+ULONG STDCALL
+RtlxOemStringToUnicodeSize (IN POEM_STRING OemString)
 {
-       return RtlAnsiStringToUnicodeSize((PANSI_STRING)OemString);
+  return RtlAnsiStringToUnicodeSize ((PANSI_STRING)OemString);
 }
 
 
-ULONG
-STDCALL
-RtlxUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
+/*
+ * @implemented
+ */
+ULONG STDCALL
+RtlxUnicodeStringToAnsiSize (IN PUNICODE_STRING UnicodeString)
 {
-       return RtlUnicodeStringToAnsiSize(UnicodeString);
+  return RtlUnicodeStringToAnsiSize (UnicodeString);
 }
 
 
-ULONG
-STDCALL
-RtlxUnicodeStringToOemSize(IN  PUNICODE_STRING UnicodeString)
+/*
+ * @implemented
+ */
+ULONG STDCALL
+RtlxUnicodeStringToOemSize (IN PUNICODE_STRING UnicodeString)
 {
-       return RtlUnicodeStringToAnsiSize(UnicodeString);
+  return RtlUnicodeStringToAnsiSize (UnicodeString);
 }
 
 /* EOF */