Skip to content

Commit 5b4f2cd

Browse files
committed
[REGEDIT] Fix import of ASCII file writing Unicode data
Test text of ASCII file using "hex()" data for presence of Unicode. CORE-15185
1 parent 7c3d4a0 commit 5b4f2cd

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

base/applications/regedit/regproc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ struct parser
142142
void *data; /* value data */
143143
DWORD data_size; /* size of the data (in bytes) */
144144
BOOL backslash; /* TRUE if the current line contains a backslash */
145+
#ifdef __REACTOS__
146+
BOOL unicode_in_asc; /* TRUE if ASCII file contains Unicode entry */
147+
#endif
145148
enum parser_state state; /* current parser state */
146149
};
147150

@@ -307,6 +310,24 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line)
307310

308311
const struct data_type *ptr;
309312

313+
#ifdef __REACTOS__
314+
DWORD len = wcslen(*line);
315+
316+
parser->unicode_in_asc = FALSE;
317+
318+
if (!parser->is_unicode && len >= 15)
319+
{
320+
WCHAR Buffer[16] = { 0 };
321+
WCHAR* ret;
322+
323+
memcpy(Buffer, *line, 30);
324+
Buffer[_countof(Buffer) - 1] = UNICODE_NULL;
325+
326+
ret = wcsstr(Buffer, L"00,"); // Any UNICODE characters?
327+
parser->unicode_in_asc = (ret != NULL);
328+
}
329+
330+
#endif
310331
for (ptr = data_types; ptr->tag; ptr++)
311332
{
312333
if (wcsncmp(ptr->tag, *line, ptr->len))
@@ -473,7 +494,11 @@ static void prepare_hex_string_data(struct parser *parser)
473494
if (parser->data_type == REG_EXPAND_SZ || parser->data_type == REG_MULTI_SZ ||
474495
parser->data_type == REG_SZ)
475496
{
497+
#ifdef __REACTOS__
498+
if (parser->is_unicode || (!parser->is_unicode && parser->unicode_in_asc))
499+
#else
476500
if (parser->is_unicode)
501+
#endif
477502
{
478503
WCHAR *data = parser->data;
479504
DWORD len = parser->data_size / sizeof(WCHAR);

0 commit comments

Comments
 (0)