Code page seems to be broken
See original GitHub issueI wrote a simple cpp code βprogram.cppβ, encoding in utf8, for only printing a chinese string:
#include<iostream>
int main()
{
std::cout << "εεεεεε" << std::endl;
return 0;
}
But it actually printed a wrong string:
> g++ .\program.cpp
> .\a.exe
ιε ζ±ιε ζ±ιε ζ±
cmd & powershell
The current code page of cmd or powerhsell is 936-gbk. But I can use chcp 65001 to solve this problem:
>a.exe
ιε ζ±ιε ζ±ιε ζ±
>type program.cpp
#include<iostream>
int main()
{
std::cout << "ιε ζ±ιε ζ±ιε ζ±" << std::endl;
return 0;
}
Active code page: 65001
>a.exe
εεεεεε
>type program.cpp
#include<iostream>
int main()
{
std::cout << "εεεεεε" << std::endl;
return 0;
}
pwsh
The current code page is 65001-utf8. I cannot get correct chinese strings printed, and chcp 65001 doesnβt work.
> .\a.exe
ιε ζ±ιε ζ±ιε ζ±
> cat .\program.cpp
#include<iostream>
int main()
{
std::cout << "εεεεεε" << std::endl;
return 0;
}
Active code page: 65001
> .\a.exe
ιε ζ±ιε ζ±ιε ζ±
> cat .\program.cpp
#include<iostream>
int main()
{
std::cout << "εεεεεε" << std::endl;
return 0;
}
Environment data
zh-cn win10.
> $PSVersionTable
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0β¦}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Windows codepage is broken - character encoding
So it seems that my codepage became broken or something... I believe it should be Windows-1251 . But I don't know/remeber is there...
Read more >What to Do When Your Website is Broken
In this this article, we will show you 7 general steps to fix your website, application, or code when it's broken.
Read more >Website weirdly broken - html
Unfortunately, CodeAnywhere seems to have the same issue. Do you have an earlier version of the code that you can open inΒ ...
Read more >We're sorry but this feature appears to be broken and ...
I just started to get this message this morning" We're sorry but this feature appears to be broken and needs to be repaired....
Read more >My code is broken somewhere and I can't find the error.
Hello! I have run through the video multiple times checking for syntax and also downloaded the project files, which didn't help, however...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

(If your application requires a specific codepage to be active, it should set it itself. It is almost always incorrect to rely on the global state of the console, because it will rarely be what you want.)
Your program does not set a code page. https://stackoverflow.com/questions/45575863/how-to-print-utf-8-strings-to-stdcout-on-windows