[TXT2NLS] TransUniDefaultChar has to be received from WideCharTable. TransDefaultChar...
authorDmitry Chapyshev <dmitry@reactos.org>
Sat, 17 Sep 2016 20:03:13 +0000 (20:03 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Sat, 17 Sep 2016 20:03:13 +0000 (20:03 +0000)
svn path=/trunk/; revision=72708

rosapps/applications/devutils/txt2nls/nls.c
rosapps/applications/devutils/txt2nls/precomp.h
rosapps/applications/devutils/txt2nls/txt.c

index 6067736..02d84ba 100644 (file)
@@ -131,6 +131,21 @@ nls_from_txt(const char *txt_file_path, const char *nls_file_path)
     /* GLYPHTABLE optionally. We do not leave if it is absent */
     glyph_table = txt_get_glyph_table(txt_file_path, header.UniDefaultChar);
 
+    if (is_dbcs)
+    {
+        /* DBCS codepage */
+        uint16_t *table = (uint16_t*)wc_table;
+        header.TransUniDefaultChar = table[header.UniDefaultChar];
+        /* TODO: TransDefaultChar for DBCS codepages */
+    }
+    else
+    {
+        /* SBCS codepage */
+        uint8_t *table = (uint8_t*)wc_table;
+        header.TransUniDefaultChar = table[header.UniDefaultChar];
+        header.TransDefaultChar = mb_table[LOBYTE(header.DefaultChar)];
+    }
+
 #ifdef _NLS_DEBUG_PRINT
     nls_print_header(&header);
     nls_print_mb_table(mb_table, header.UniDefaultChar);
index d0b3839..7c6ee49 100644 (file)
@@ -15,6 +15,8 @@
 #include <ctype.h>
 #include <memory.h>
 
+#define LOBYTE(w) ((uint8_t)((uint32_t)(w) & 0xff))
+
 #define MAXIMUM_LEADBYTES   12
 
 typedef struct
index 56acb04..abf4dd2 100644 (file)
@@ -96,6 +96,7 @@ txt_get_header(const char *file_path, NLS_FILE_HEADER *header)
             /* Convert string to uint32_t */
             val = strtoul(p, &p, 16);
             header->DefaultChar = (uint16_t)val;
+            /* By default set value as DefaultChar */
             header->TransDefaultChar = (uint16_t)val;
 
             /* Skip all spaces after default char */
@@ -104,6 +105,7 @@ txt_get_header(const char *file_path, NLS_FILE_HEADER *header)
             /* Convert string to uint32_t */
             val = strtoul(p, &p, 16);
             header->UniDefaultChar = (uint16_t)val;
+            /* By default set value as UniDefaultChar */
             header->TransUniDefaultChar = (uint16_t)val;
 
             found = 1;