D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20384 - UTF-8 vital error for chinese character which to be printed in console
Summary: UTF-8 vital error for chinese character which to be printed in console
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-11 16:14 UTC by ll
Modified: 2024-12-13 19:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ll 2019-11-11 16:14:04 UTC
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

}
Comment 1 dlangBugzillaToGithub 2024-12-13 19:06:10 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17927

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB