User forums > Help
Console printing erroneous Japanese characters
Shademp:
For example this set of character in the Code::Blocks IDE "燼うぬむ味厩" becomes printed as "辯シ縺・〓繧蜻ウ蜴ゥ" in the cmd.
In Visual Studio 2017 the symbols print correctly, but I'd prefer to continue working in Code::Blocks if possible.
--- Code: ---#include <iostream>
#include <stdio.h>
#include <cwchar>
#include <windows.h>
int main()
{
system("chcp 932 > nul");
cout << "燼うぬむ味厩" << endl;
return 0;
}
--- End code ---
I am aware of wcout but when I use that no text gets printed at all in the cmd. Given that my 6 symbols become interpreted as 12 symbols in total, it seems I need to hard-enable wide characters but so far I have failed in doing so.
Additional notes:
- File encoded in UTF-8, my program refuses to accept UTF-16 in any shape or form
- My Japanese-compatible cmd font is MS Gothic
- OS is Windows 8.1
- Visual Studio printed the text correctly whether I used cout or wcout
Thanks in advance for any suggestions on how to proceed.
stahta01:
The easiest solution to use code that works with your compiler and OS.
No idea what compiler you are using; but, guessing MinGW GCC; the work around was posted for that group of compilers somewhere on this forum.
You might try searching the forum after you read the FAQs and search the wiki page.
Tim S.
BlueHazzard:
this is probably some unicode problem. Either your file has the wrong encoding or your console, or your compiler...
Some steps you can try:
http://forums.codeblocks.org/index.php/topic,18803.msg128791.html#msg128791
or even better:
http://forums.codeblocks.org/index.php/topic,22168.msg150872.html#msg150872
Shademp:
My apologies for posting this in the wrong section. Had I read the forum instructions in more detail I would have known to post this newbie question in the "Using Code::Blocks" section instead. Feel free to move or delete this thread.
Thank you Tim for pointing me in the direction of compilers. I would have not considered that to be the issue otherwise and now I appreciate the difference between Code::Blocks and compilers. I am using the mingw32-g++ compiler that came packaged with my C::B installation. To confirm 100% that my issue is compiler-related, I installed MinGW properly and ran my program via that path, no C::B involved.
Indeed, the same garbled text got printed even without the C::B. The only difference is that the erroneous symbol € became a padding space. While my newly installed MinGW compiler appears to be from 2017, with the compiler in the C::B package being from 2015, I am still assuming that my issue is indeed the compiler.
Searching for the solution on the forum has proven fruitless on my end however. I've tried searching using keywords like "unicode", "compiler", "encoding", "wide character" etc but nothing presents itself to me as the solution. Granted I could be reading the solution and still not know it's there, due to how new I am to the world of programming.
The closest that my eyes signal as potentially related to the solution are these wiki pages:
- Unicode Standards
- Code::Blocks variable types synthesis
There is a lot of talk about this "wxWidgets" thing all over the forum. Is it recommended that I install that and learn how it works? Will that bring me closer to the solution?
I shall not try the patience of the forum beyond this post but once again I appreciate any pointers in the right direction. Thanks in advance.
stahta01:
--- Quote from: BlueHazzard on November 08, 2018, 12:52:20 am ---this is probably some unicode problem. Either your file has the wrong encoding or your console, or your compiler...
Some steps you can try:
http://forums.codeblocks.org/index.php/topic,18803.msg128791.html#msg128791
or even better:
http://forums.codeblocks.org/index.php/topic,22168.msg150872.html#msg150872
--- End quote ---
The solution was posted already in this thread!
Navigation
[0] Message Index
[#] Next page
Go to full version