Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I can only speak about Windows for now. On Windows, code pages are only meant for legacy applications and not used by the system or by modern applications. Windows uses UTF-16 (and has done so for ages) for everything: text display, file names, the terminal, the system API. Conversions between UTF-16 and the legacy code pages are only performed at the highest possible level, directly at the interface between the system and the application (technically, the older API functions are implemented twice—one function <code>FunctionW</code> that does the real work and expects UTF-16 strings, and one compatibility function <code>FunctionA</code> that simply converts input strings from the current (thread) code page to UTF-16, calls the <code>FunctionW</code>, and converts back the results). Tab-completion should always yield UTF-16 strings (it definitely does when using a TrueType font) because the console uses only UTF-16 as well. The tab-completed UTF-16 file name is handed over to the application. If now that application is a legacy application (i.e., it uses <code>main</code> instead of <code>wmain</code>/<code>GetCommandLineW</code> etc.), then the Microsoft C runtime (probably) uses <code>GetCommandLineA</code> to have the system convert the command line. So basically I think what you're saying about Windows is correct (only that there is probably no conversion involved while tab-completing): the <code>argv</code> array will always contain the arguments in the code page of the <em>current</em> application because the information what code page (L1) the <em>original</em> program has uses has been irreversibly lost during the intermediate UTF-16 stage.</p> <p>The conclusion is as always on Windows: Avoid the legacy code pages; use the UTF-16 API wherever you can. If you have to use <code>main</code> instead of <code>wmain</code> (e.g., to be platform independent), use <code>GetCommandLineW</code> instead of the <code>argv</code> array.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload