[Issue 20384] New: UTF-8 vital error for chinese character which to be printed in console
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 11 16:14:04 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20384
Issue ID: 20384
Summary: UTF-8 vital error for chinese character which to be
printed in console
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: aliule2020 at 163.com
import std.stdio;
import core.stdc.stdio;
import core.stdc.stdlib;
void main()
{
system("chcp 65001");// change code page to utf-8
system("cls"); //clear the console
writeln("你好啊世界");//OK
//string str="123456"; // if str is ascii, the correct result will be get
string str="你好啊世界"c;
//if str is chinese characters, the wrong result will be get
char[] chs=str.dup;
for(int i=0;i<chs.length;i++)
{
writeln(chs[i]);//both number and content of chinese are wrong
}
system("pause");//pause
}
--
More information about the Digitalmars-d-bugs
mailing list