[TXT2NLS] TransUniDefaultChar has to be received from WideCharTable. TransDefaultChar has to be received from MultiByteTable (or from DBCS table)

svn path=/trunk/; revision=72708
This commit is contained in:
Dmitry Chapyshev 2016-09-17 20:03:13 +00:00
parent c75bd6ee1e
commit 40a137dfa8
3 changed files with 19 additions and 0 deletions

View 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);

View 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

View 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;