User forums > Help
Weird foreign letters problem...
oBFusCATed:
It is not a conspiracy just complexity. Generally it is not a good idea to do what you want to do. At least in c++.
The link posted by bluehazzard looks good.
BlueHazzard:
--- Quote ---
--- Quote ---While your fix provided in the link works, I can not use it, because I must use 'cout << " " << endl;', 'cin >> x;', etc.
--- End quote ---
--- End quote ---
From the linked forum thread:
--- Quote ---[EDIT:] You can use std::cout with this method. If it is not working you have to update your compiler, or use utf8 literals that are supported by c++11
--- End quote ---
So to sum up, you have 3 problems:
1) The Letters you enter in codeblocks show as squares
2) The letters you enter in your code do not show correctly in the console window
3) You write letters in codeblocks, they seem fine, you save and after reopening the file, the letters are not the same as you saved?
Is this right?
All this are unicode problems that are not easy... Unicode is a hard problem... that is why i only use ascii, because on different systems and on different places in the world this is handled different. The problem is that at this time on normal programming no one has standardized one way to go. (On the web luckily we have UTF-8 as standard). I will not go into details about this, but it is not easy to solve....
1) This is an ecoding and font problem. You have to save the files with an encoding that support your letters (code points) and your font has to support this encoding and has to contain symbols for your code points (letters). On windows "Lucida Console" is a UTF-8 font with many supported code points, so i suggest you use this font for your code, or you download some from the google font page https://www.google.com/get/noto/
2) This is also a problem with unicode and fonts, i think i have described in the other forum thread what you should do..
3) This is an encoding problem. At this point you have to decide what encoding you want to use. Your windows system encoding (some garbage utf 16 s***t) or the proper way to utf-8 glorious master race.
If you decide the utf-8 way set all your editor encodings to this:
Settings->Editor->General settings->Encode settings->Use encoding when opening files: utf-8
Make sure your file are utf-8 encoded: Open each file, look at the bottom in the status bar, if there is written "utf-8" or some garbage "windows-xx" encoding. If there is later go to Edit->File encoding->UTF-8
REMEMBER: You can not copy and paste things around like you want with unicode signs. If you have a text document encoded in some strange windows codepage and you copy and paste letters from there to an utf-8 encoded file i do not think that it would work. I do not know if codeblocks makes an automatic transformation between encodings in the copy and paste part....
I should really collect all this in one place... There are a lot unicode questions lately...
oBFusCATed:
--- Quote from: BlueHazzard on November 23, 2018, 09:59:02 am ---I should really collect all this in one place... There are a lot unicode questions lately...
--- End quote ---
A wiki page would be great. It would be also useful if you test what happens with copy-pasting... Probably we should at least warn that something is wrong.
5Nick7:
--- Quote from: BlueHazzard on November 23, 2018, 09:59:02 am ---So to sum up, you have 3 problems:
1) The Letters you enter in codeblocks show as squares
2) The letters you enter in your code do not show correctly in the console window
3) You write letters in codeblocks, they seem fine, you save and after reopening the file, the letters are not the same as you saved?
Is this right?
--- End quote ---
Correct, the 3) problem happens when I use the block of code in my very first post, nothing about 2) and 1). But, if I change my encoding to UTF-8, then problem 3) disappears, instead 2) and 1) come. Does this make sense?
--- Quote from: BlueHazzard on November 23, 2018, 09:59:02 am ---
--- Quote ---
--- Quote ---While your fix provided in the link works, I can not use it, because I must use 'cout << " " << endl;', 'cin >> x;', etc.
--- End quote ---
--- End quote ---
From the linked forum thread:
--- Quote ---[EDIT:] You can use std::cout with this method. If it is not working you have to update your compiler, or use utf8 literals that are supported by c++11
--- End quote ---
--- End quote ---
Sorry for being so... what's the word? Demanding? But I need specifically 'cout', not 'std::cout' or 'wcout'...
BlueHazzard:
Ok, i have retried this and was not able to make the cout part working in the normal console... Only in ConEMU it worked, but there only the cout part. Cin never worked.
And i think it will never be possible, with utf8. Windows made a big pile of shit here.... I read of some rumors that with the latest build of windows 10 they introduced a true utf8 codepage, but i can not test it, because i do not have windows 10...
What can you do? If you want to use unciode i am not sure. You can probably try to use the codepage of your language. I do not know if this 128 characters are enough for your language. If not you will need wcout and a lot of other trash...
If you want to use your codepage, all files have to be the same encoding. And also the console has to use this encoding, you have to set it with the system("chcp 65001 > nul"); call.
You will have to try it.... The most important thing is to keep in sync all encoding settings, from the file in codeblocks, to the console font and encoding setting...
Would be nice if you could report back if you succeed...
Navigation
[0] Message Index
[*] Previous page
Go to full version