Hey guys, when i run the program, i cant see the letters just like i writed them. For example:
Whenever i write "[B]Ą[/B]" i get "[B]A[/B]";
Whenever i write "[B]Č[/B]" i get "[B]C[/B]";
Etc.
Maybe you know why im getting this problem?
[B]#include <iostream>
#include <locale>
using namespace std;
int main()
{
setlocale(LC_ALL,"Lithuanian");
cout << "ĄČĘĖĮŠŲŪ" << endl;
return 0;
}[/B]
[QUOTE=Matkenis;44089094]Hey guys, when i run the program, i cant see the letters just like i writed them. For example:
Whenever i write "[B]Ą[/B]" i get "[B]A[/B]";
Whenever i write "[B]Č[/B]" i get "[B]C[/B]";
Etc.
Maybe you know why im getting this problem?
[B]#include <iostream>
#include <locale>
using namespace std;
int main()
{
setlocale(LC_ALL,"Lithuanian");
cout << "ĄČĘĖĮŠŲŪ" << endl;
return 0;
}[/B][/QUOTE]
Make sure to have your source file encoded in UTF-8. If that doesn't help (depending on the compiler), you could either use wide strings (not very portable) or stick with ASCII and escape your non-ascii characters in some unicode encoding. Then ensure that your output medium can interpret the encoding you chose (e.g. the console on Windows can be explicitly run in unicode mode).
Thanks, where do i find output medium?
With output medium I meant whereever you redirect STDOUT to. It could be a console or terminal, it could be a file, a host program, a printer, a network, ...
For example, if you encode in UCS2 and write to a file, view that file with a software that can handle UCS2 encodings.
[editline]1st March 2014[/editline]
I should add that locales in C++ do not allow you to use certain charsets. It's just cultural data context that will affect certain processings and outputs, e.g. determining what decimal point notation is used.
[QUOTE=Dienes;44089894]With output medium I meant whereever you redirect STDOUT to. It could be a console or terminal, it could be a file, a host program, a printer, a network, ...
For example, if you encode in UCS2 and write to a file, view that file with a software that can handle UCS2 encodings.
[editline]1st March 2014[/editline]
I should add that locales in C++ do not allow you to use certain charsets. It's just cultural data context that will affect certain processings and outputs, e.g. determining what decimal point notation is used.[/QUOTE]
Well, at my school i tried this and it worket perfectly fine. I will try to fix it, thanks!
Sorry, you need to Log In to post a reply to this thread.