bitwiseworks / qtwebengine-chromium-os2

Port of Chromium and related tools to OS/2
9 stars 2 forks source link

gn: Support local code page for file names #2

Open dmik opened 4 years ago

dmik commented 4 years ago

This is a continuation of https://github.com/bitwiseworks/qtwebengine-os2/issues/3.

Currently, GN assumes that all file names are in UTF-8 on OS/2 (as well as on all other POSIX platforms). This is, however, not true as on OS/2 they are in a local code page (e.g. CP437 for US, CP855 for EU or CP866 for RU). It works fine as is as long as no national (non-ASCII) characters are used in file names. However, once such a character appears, it will most likely produce an invalid UTF-8 sequence and GN may fail.

Since it's unlikely that such files will appear at this stage of development (and the main focus is to build Chromium ASAP) it is postponed until we get a real case.

dmik commented 4 years ago

Here is the list of GN source files where such encoding should take place:

ninja_build_writer.cc
filesystem_utils.cc
gn_main.cc
function_exec_script.cc
environment.cc

Look for OS_WIN in those sources — Windows converts UTF-16 (the standard file name encoding in modern versions) to UTF-8 there. OS/2 should convert from multi byte (local code page) to UTF-8. The simplest way to do so first convert to a wide string (UTF-16) with LIBC mbstowcs and then from it to UTF-8 using the Windows code path.