Fixing C++ Turkish Character Error
Fixing C++ Turkish Character Error
Hello friends, in this post I will explain how to fix the issue of corrupted Turkish characters encountered while developing console applications with C++, or rather how you can correct it with a tiny bit of code. Happy reading.
First, let's look at the starting code of our project and its result.
As you can see, it's a standard code created in Visual Studio and we just changed the "Hello World" part to "Türkçe Karakter!".
As you can see, the text that appears is displayed as "T³rke Karakter!". There are problems with the letters ü and ç; in the same way, if we had used capital İ, we would have seen problems there as well.
To solve our problem, we add the locale.h library and then write "setlocale(LC_ALL,\"TURKISH\");" as the very first line in main.
When we add the code as above, our problem is resolved.
If we need to share all our code ;
#include <iostream>
#include <locale.h>
int main()
{
setlocale(LC_ALL, "Turkish");
std::cout << "Türkçe Karakter!\n";
}


Yorum Gönder