[Issue 2742] std.stdio assumes console works in utf-8

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 24 20:05:27 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=2742



--- Comment #9 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-05-24 20:01:07 PDT ---
According to this page http://codesnippets.joyent.com/posts/show/414
you can get and set the codepage via the
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage] key's OEMCP
value.

Setting the codepage requires a restart though. Also, changing the codepage has
other effects, e.g. using ALT+Numpad keys is handled differently (with codepage
1252 you don't have to prepend a zero when using ALT+Numkey apparently).

Here's how to fetch the value:
import std.stdio;
import std.windows.registry;

void main()
{
    Key HKLM  = Registry.localMachine;
    Key SFW = HKLM.getKey(r"SYSTEM\CurrentControlSet\Control\Nls\CodePage");    

    auto codePage = SFW.getValue("OEMCP").value_SZ();
    writeln(codePage);
}

Note that the key type is REG_SZ, a string, not a binary value. So if you want
to set the code page programmatically, you have to call:
SFW.setValue("OEMCP", "1252");

One more thing, there was this comment:
"Change the code page in your registry and you may not be able to reboot your
windows anymore."

That sounds kind of scary. Perhaps all of this should be left to the user to do
and just document it somewhere in the docs.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list