Last active
February 3, 2025 23:52
-
-
Save doccaico/180486dbbdbbff52b66f30b1947513ce to your computer and use it in GitHub Desktop.
Dlangで日本語出力 (cmd.exe and powershell.exe)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio : writeln; | |
import std.conv : to; | |
import std.windows.charset : toMBSz; | |
import core.sys.windows.windows : GetConsoleOutputCP; | |
void main() | |
{ | |
auto currentCodePage = GetConsoleOutputCP(); | |
writeln(currentCodePage); | |
string utf8_string = "あいうえお"; // UTF8 | |
writeln("utf8 to sjis: ", to!string(toMBSz(utf8_string))); | |
writeln("utf8 to sjis: ", to!string(toMBSz(utf8_string, 932))); | |
// $ rdmd jp.d | |
// | |
// 932 | |
// utf8 to sjis: あいうえお | |
// utf8 to sjis: あいうえお | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment