« first day (1758 days earlier)      last day (1095 days later) » 

8:47 AM
To my previous problem,. It seems like std::string cant handle utf-8 or something like that, whit is unfortunatelly output from std::ifstream
 
nwp
std::string doesn't handle encodings at all, it only stores bytes.
Are you on Windows using cmd.exe?
 
no, windows visual studio
 
nwp
66
A: How to print Unicode character in C++?

bames53To represent the character you can use Universal Character Names (UCNs). The character 'ф' has the Unicode value U+0444 and so in C++ you could write it '\u0444' or '\U00000444'. Also if the source code encoding supports this character then you can just write it literally in your source code. //...

 
or maybe Im using std::local wrong
 
nwp
You'll have to make the output of your program match the encoding of the shell.
Chances are it wants UTF-16 and not UTF-8.
 
8:54 AM
Im pretty convinced that japanese need UTF-16
 
nwp
I'm sure you can use UTF-8 for Japanese just fine, but if you output UTF-8 Japanese and the shell expects UTF-16 then you get garbage.
 
you mean that win console?
 
nwp
Yes
There might be a way to query or set the shell's encoding. Or tell the shell what encoding your program uses. I don't really know. Normally everyone uses UTF-8 for everything, but Windows' cmd is an outlier.
 
ahhh,. now I hate windows a bit more :D
I found there is currently set this in console: 852 ibm852 OEM Latin 2; Central European (DOS)
Hmm - I know that from std::locale, windows code for it is for example for CZ = Czech_Czechia.1250, so I set console to: windows-1250 ANSI Central European; Central European (Windows), but stil getting garbage from debug console
It should be: Aktuélně je vybraná čeština. Output is: AktuálnÄ> je vybrána ÄŤeština., so maybe there is other problam that sync with cmd?
 
nwp
9:19 AM
I haven't messed with locales. One thing I'd try is to do std::cout << "Aktuélně je vybraná čeština"; without any settings and see if that works. If it does you have a starting point and can inspect the bytes of that string and maybe figure out the encoding.
An alternative that bypasses the problem is to use another shell. Git bash or something. That should understand UTF-8.
Another alternative is to open a window with a text edit inside it. Maybe that doesn't interfere too much with what you want to do.
 
Czech lang works that way, I already tryed it before,. Thats wy I thought its problem at std::string.. But If I try absolutelly diferrent language like russian. Im trying something with coding in programm settings, but cant find where it is in menu..
 
nwp
My guess is it's set to the Czech locale so you can only use characters on that list. Since it has Czech characters but not Japanese characters you can print Czech fine but not Japanese.
277
Q: What encoding/code page is cmd.exe using?

Dan Gøran LundeWhen I open cmd.exe in Windows, what encoding is it using? How can I check which encoding it is currently using? Does it depend on my regional setting or are there any environment variables to check? What happens when you type a file with a certain encoding? Sometimes I get garbled characters (...

That is probably also helpful.
And as they point out, maybe using WriteConsole instead of std::cout is the way to make this work properly.
If you care about platform independence you can make a std::cout-like object that either forwards to WriteConsole on Windows or std::cout elsewhere guarded by an #ifdef.
 
9:45 AM
I will try it,. but currently Im stucked on that when I put russian text in visual studio, at save it popup menu that required coding change to save it properly,. I found some utf8 and set it,. now I can save,. but dont know id of that coding and cant find that popup menu manually
so I cant sync cmd with that coding
Im sure its the issue now, becausse as output its showing ""?????????????????
I read something like edit config should contain that coding info, just need to find what and where is it
 
nwp
If you do std::cout << "Aktuélně je vybraná čeština"; it probably fails as well.
C++ says that string literals are encoded the way that the source file is encoded. It probably defaulted to cp852 before which matched what cmd expects, but now that it's UTF-8 it doesn't work anymore.
Keeping the source file encoded as UTF-8 makes perfect sense. Changing the encoding so some Russian encoding should not allow you to write Russian characters with std::cout.
It might actually make sense to save as UTF-16 and then use WriteConsole. That should allow you to print everything directly, including Japanese.
When you read from somewhere you should try to read it in UTF-16 or convert it to that.
You should also try std::wcout << L"Aktuélně je vybraná čeština"; at some point.
There is also a chance that std::wcout << L"こんにちは "; just works.
 
this works: std::cout << "Aktuálně je vybraná čeština" << std::endl;
std::wcout make this a bit messy: Aktuálni je vybraná ee
and it even ignore std::endl
Im still looking for that project coding settings,. at some user settings file I found his xml: <?xml version="1.0" encoding="utf-8"?> but its not full id of that encoding
 
nwp
10:02 AM
What do you mean by "full id"?
UTF-8 is UTF-8. There are no code pages in it, that's the entire name.
 
if you mean locales, then yeah they might have more info, but a locale is more than just encoding
 
maybe that would be it. It should look like this : 12001 Unicode UTF-32,
I need that long namber so I can make some tests
This way it was displayed at that popup of visual studio while saving
 
@IrinelIovan I think I am fine. I'd rather have a good fee for known work and not the incertainties of having a stake in someone else's business. I'll mail a plan tomorrow.
 
 
2 hours later…
12:20 PM
finally some progress,. I convert from string u8 to wstring utf16 and using sf::text to display. Czech language seem working fine., however I will tell you a funny story :D
this is name description of free google multilanguage font I found: “Noto” means “No Tofu.” Tofu is the standing rectangle symbol that you see when the said fonts are not supported on your device. However, first language I tryed fires a whole lines of "Tofu". Soo thats the story. Im getting hangry.
 
1:02 PM
seems like the problem it donst display properly is from font, So it seems like all is ok,. dont enven need sync with win cmd or std::locale
 

« first day (1758 days earlier)      last day (1095 days later) »