Author: dchapyshev
Date: Sun Sep  4 22:57:44 2016
New Revision: 72580

URL: http://svn.reactos.org/svn/reactos?rev=72580&view=rev
Log:
[RTL]
- Implement RtlIsValidOemCharacter function

* Fixes all new tests for this function

Modified:
    trunk/reactos/sdk/lib/rtl/nls.c
    trunk/reactos/sdk/lib/rtl/unicode.c

Modified: trunk/reactos/sdk/lib/rtl/nls.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/nls.c?rev=72580&r1=72579&r2=72580&view=diff
==============================================================================
--- trunk/reactos/sdk/lib/rtl/nls.c     [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/rtl/nls.c     [iso-8859-1] Sun Sep  4 22:57:44 2016
@@ -29,7 +29,7 @@
 USHORT NlsOemCodePage = 0;
 BOOLEAN NlsMbOemCodePageTag = FALSE; /* exported */
 PWCHAR NlsOemToUnicodeTable = NULL;
-PCHAR NlsUnicodeToOemTable =NULL;
+PCHAR NlsUnicodeToOemTable = NULL;
 PWCHAR NlsDbcsUnicodeToOemTable = NULL;
 PUSHORT NlsOemLeadByteInfo = NULL; /* exported */
 

Modified: trunk/reactos/sdk/lib/rtl/unicode.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/unicode.c?rev=72580&r1=72579&r2=72580&view=diff
==============================================================================
--- trunk/reactos/sdk/lib/rtl/unicode.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/rtl/unicode.c [iso-8859-1] Sun Sep  4 22:57:44 2016
@@ -24,6 +24,9 @@
 extern PUSHORT NlsLeadByteInfo;
 extern USHORT NlsOemDefaultChar;
 extern USHORT NlsUnicodeDefaultChar;
+extern PUSHORT NlsOemLeadByteInfo;
+extern PWCHAR NlsOemToUnicodeTable;
+extern PCHAR NlsUnicodeToOemTable;
 
 
 /* FUNCTIONS *****************************************************************/
@@ -503,14 +506,47 @@
 }
 
 /*
-* @unimplemented
+* @implemented
 */
 BOOLEAN
 NTAPI
 RtlIsValidOemCharacter(IN PWCHAR Char)
 {
-    UNIMPLEMENTED;
-    return FALSE;
+    WCHAR UnicodeChar;
+    WCHAR OemChar;
+    UCHAR Index;
+
+    /* If multi-byte code page present */
+    if (NlsMbOemCodePageTag)
+    {
+        USHORT Offset = 0;
+
+        OemChar = NlsUnicodeToOemTable[*Char];
+
+        /* If character has Lead Byte */
+        if (NlsOemLeadByteInfo[HIBYTE(OemChar)])
+            Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)];
+
+        Index = LOBYTE(OemChar) + Offset;
+    }
+    else
+    {
+        Index = NlsUnicodeToOemTable[*Char];
+    }
+
+    /* Receive Unicode character from the table */
+    UnicodeChar = RtlUpcaseUnicodeChar(NlsOemToUnicodeTable[Index]);
+
+    /* Receive OEM character from the table */
+    OemChar = NlsUnicodeToOemTable[UnicodeChar];
+
+    /* Not valid character, failed */
+    if (OemChar == NlsOemDefaultChar)
+        return FALSE;
+
+    *Char = UnicodeChar;
+
+    return TRUE;
 }
 
 /*


Reply via email to