I couldn't solve Turkish character problem in C++.If I use wstring for a Turkish
character,writing:
wstring TurkishCharacters;
and then :
TurkishCharacter=L"çı"; // I don't know if you are able to see the Turkish characters
// "ç",it is a character similar to "c" and the other character
// is similar to "i" but a bit different.
It gives this error:
"... error: converting to execution character set: Invalid argument"
You shouldn't put extended character literals in your source code - because how those characters are treated by the compiler is implementation defined. Read more about it here: http://www.codeguru.com/forum/showpo...8&postcount=14
For your source code, use either L"\x00C7" or L"\u00C7".
For console output, you need to imbue the user's locale into wcout. That can be done with "wcout.imbue(locale(""));".
Under linux, you can only hope that the character encoding associated with the user's locale understands that character.
Under Windows, this still isn't enough. With VS2008 and higher, you can add "_setmode(_fileno(stdout), _O_U16TEXT);". Then you just have to use a console font (like Lucida Console) that has glyphs for the characters you're trying to output.
TurkishCharacter=L"çı"; // I don't know if you are able to see the Turkish characters
And that is the problem right there.
You asked us "if you are able to see the Turkish characters". Why did you ask us this question? If everyone wasn't able to see those characters, then what makes you think that the compiler and/or editor used will see the same thing you're seeing? What if we're using a browser that doesn't display what you typed correctly? See all of the problems now?
Use hex codes if you know the exact hex value for the characters. Once you do that, then whatever the platform's environment is set for when you run the program will display something -- it may be Turkish character, a Chinese character, an Arabic character, who knows. Once you get to that stage, then you figure out how your OS works in terms of displaying the correct characters.
It didn't print anything on the screen.Did you mean hex characters like Codeplug said?If yes,I tried "converting" =0xDE into u00DE and it printed a very similar character to a Turkish character but not exactly.
Codeplug,before I wrote your code,I tried with just:
It printed an interesting character which looks like "A" but a bit different,it is not a Turkish character.Then I wrote your code exactly,and the result was same,it printed the same character.
So,I think if I can find which hex code equal to Turkish character which I am trying to use,it will solve my problem,like you said.Now the problem is,how I can find hex code list
So,I think if I can find which hex code equal to Turkish character which I am trying to use,it will solve my problem,like you said.Now the problem is,how I can find hex code list
Second, instead of trying to find this one character, write a loop that displays all the characters, so that you see right away what hex code to use for any character you're interested in. Trying to hunt down one single character by trial and error is not the way to solve this problem.
Code:
#include <string>
#include <iostream>
unsigned int start, last;
using namespace std;
int main()
{
cout << "Enter starting value: ";
cin >> start;
cout << "\nEnter ending value: ";
cin >> last;
for (unsigned int i = start; i <= last; ++i )
wcout << i << " - " << wstring(1, i) << endl;
}
Enter two decimal values denoting the start and ending character value. Then you will see all of the characters associated with those numbers. You just need to translate the decimal to hex yourself (or change the program to do that for you). In any event, this is how you figure out characters and their associated representation.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; August 15th, 2010 at 04:18 PM.
They print different characters but none of them is the character equal to the character in the list.
Also writing
cout << "\0x00FA";
or any other hex code like this prints nothing on the screen...only L"\u00FA" or L"\x00FA" style is working...Did you mean L"\x00FA"(no 0 before x) like Codeplug said?
Also I tried the codes you gave,in the list the codes generated,for example "152" was equal to a character which I want to use.Then I converted it to hex with an online converter,the result was "98".Now what should I do with "98"?
Last edited by AwArEnEsS; August 15th, 2010 at 10:08 PM.
The characters don't match with those in the list you gave,interesting.Although some characters match(especially Enghlish characters) most of the others don't match...
In the webpage you gave,I have found a few other lists (like Turkish Windows Oem) and ISO but none of them matches exactly...
Turkish characters I am trying to write in code are "çÇğĞıİöÖşŞüÜ".
">> for example "152" was equal to a character which I want to use.
What character is that? Just type/paste it in the post."
It is equal to "İ" character I think(it looks very similar but I am not sure if it's dot is a dot really or is a dash)
Last edited by AwArEnEsS; August 16th, 2010 at 01:26 PM.
The same problem continued with "Lucida Console" font.I am using Qt Creator without using Qt related code and it is using gcc compiler if I know right.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.