+ 15

Setting language locales using <locale>

I wish to change the locale settings of my terminal, so that it supports characters in Hindi. I am using Code::Blocks on Windows, and I have set the default encoding to UTF-8. So far, I tried the following : std::locale::global(std::locale("hi_IN.UTF-8")); std::locale::global(std::locale("hi_IN.UTF8")); std::locale::global(std::locale("Hindi")); But unfortunately, none of these worked for me. How can I set the locale effectively, and revert back the changes later?

5th Jul 2018, 4:31 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
13 ответов
+ 2
When last time my locals got changed it all got bugged up. I was even unable to open terminal. I don't remember perfectly but it will rise an perl error. Sorry this comment is not helping but I'm trying to convince u not to change locals. :)
5th Jul 2018, 4:39 PM
Yugabdh
Yugabdh - avatar
+ 2
YUGABDH PASHTE Thats sad to hear. I shall ask for a way to revert back the changes made later as well then, after I get a reply, that is.
5th Jul 2018, 4:44 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
There is file named locals if your trying to make any changes. Make sure that they are made in that file too. Also if u face any problem like me like failed to run terminal then there is xserver which will give you terminal if needed.
5th Jul 2018, 4:48 PM
Yugabdh
Yugabdh - avatar
0
Ace Sorry I didn't mention, but I have tried setlocale as well. Still, I wasn't able to print the characters. All I see are a bunch of ? marks.
5th Jul 2018, 5:39 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
Ace In the terminal properties, all I see is the option to change the font. From wchar.h, I just realized that there is something called wcout. Do I need to use that to print the characters? I was using the usual cout.
5th Jul 2018, 5:57 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
ye
5th Jul 2018, 8:14 PM
Viktor Rakhimov
Viktor Rakhimov - avatar
0
Ace Sorry for the delay. I tried wcout, but there was no output, not even the empty boxes or ? marks. I tried searching on the net, and found that I need to ensure that the code page is UTF 8, which I did, but even then I could not generate the correct output. Following are the code pages I have tried : 65001, 1200(UTF-16 LE), 1201 (UTF-16 BE), 1251(Default) and 57001(ISCII Devanagari Set for Hindi). It may be that my actions are not affecting the terminal at all, but I cannot confirm the same.
6th Jul 2018, 7:33 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
Also, I am unable to understand as to why the changes are not reflected. Can this be a problem due to restricted permissions in Windows? I am not running the program as an administrator.
6th Jul 2018, 7:39 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar