binutils-gdb: Fix wrong code page#383
Conversation
Binutils-gdb fetch code page for path conversion from ___lc_codepage_func(). When building with msvcrt, ___lc_codepage_func does not return the code page that file APIs accept and return, or argv encoded in; it returns "the default code page for Windows display language". When (1) checking "Beta: USE Unicode UTF-8 for worldwide language support", or (2) setting "Current system locale" to some value differ from current display language, the path is corrupted during conversion and binutils and gdb cannot use non-ASCII filenames (even they are encode-able in current code page). Also, gdb passes "CP<ACP>" to iconv, but "CP65001" is not a valid encoding name. Explicitly handling CP_UTF8 fixes it.
|
Thanks for this, @CyanoHao. I'm trying to reproduce the problem scenario. I went with option (1) and restarted. I made a file named For context, my system is set for English (United States), plus now that UTF-8 beta ticked. Both before and after your changes the above produced |
|
You have to really wonder how it's even possible for binutils to be this buggy. The more of it I read, the lower my opinion of its code quality. |

Binutils-gdb fetch code page for path conversion from ___lc_codepage_func(). When building with msvcrt, ___lc_codepage_func does not return the code page that file APIs accept and return, or argv encoded in; it returns "the default code page for Windows display language".
When (1) checking "Beta: USE Unicode UTF-8 for worldwide language support", or (2) setting "Current system locale" to some value differ from current display language, the path is corrupted during conversion and binutils and gdb cannot use non-ASCII filenames (even they are encode-able in current code page).
Also, gdb passes "CP<ACP>" to iconv, but "CP65001" is not a valid encoding name. Explicitly handling CP_UTF8 fixes it.