Best way to read/write Chinese (GBK/GB18030) files?

zjh fqbqrr at 163.com
Fri Mar 10 06:19:38 UTC 2023


On Friday, 10 March 2023 at 02:48:43 UTC, John Xu wrote:


```d
module chinese;
import std.stdio : writeln;
import std.conv;
import std.windows.charset;

int main(string[] argv)
{
	auto s1 = "中文";//utf8 字符串
	writeln("word:"~ s1); //乱的
	writeln("word:" ~ to!string(toMBSz(text(s1)))); //转后就正常了
     writeln("Hello D-World!");
     return 0;
}
```


More information about the Digitalmars-d-learn mailing list