尽管设置了“ setlocale(LC_ALL,” Turkish“);”,为什么我的字体编码无法正常工作?

问题描述 投票:-3回答:1

嗨,我对我的代码有疑问。我想我做的一切正确。但是我有字体混乱。我该如何解决?我正在使用"setlocale(LC_ALL, "Turkish");",但土耳其语符号仍无法正确解释。

这是我的代码:

//Klavyeden girilen 2 sayıdan küçüğünü bulup tekmi çiftmi olduğunu ekran 
yazdırınız...

#include "stdafx.h"
#include <iostream>

using namespace std;
int main()
{
setlocale(LC_ALL, "Turkish");
int x, y;


cout << "Birinci Sayıyı Giriniz:";
cin >> x;

cout << "İkinci Sayıyı Giriniz:";
cin >> y;

if (x < y && ((x % 2) == 0))
{
    cout << "İlk sayı ikinci sayıdan küçük ve çifttir.";
}
else if (x < y && ((x % 2) == 1))
{
    cout << "İlk sayı ikinci sayıdan küçük ve tektir.";
}
else if (y < x && ((x % 2) == 1))
{
    cout << "İlk sayı ikinci sayıdan büyük ve tektir.";
}
else
{
    cout << "İlk sayı ikinci sayıdan büyük ve çifttir..";
}



system("PAUSE");
return 0;}

这是我的代码中的文本:

enter image description here

这是显示乱码的输出:

enter image description here

c++ fonts
1个回答
0
投票

该问题可能是由于使用默认代码页850而不是UTF-8的cmd

要使cmd使用UTF-8,请执行以下操作*:

  1. 以cmd键入chcp 65001,如果不起作用,请执行以下步骤。

  2. 开始->运行-> regedit

  3. 转到[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun]
  4. 将值更改为chcp 65001

  5. 重新启动系统。

*在处理Windows注册表时,后果自负。

Source

以下是代码页编号,仅供参考,我看到您使用的是土耳其语,因此您可能还希望使用代码857Image source

Code page codes

© www.soinside.com 2019 - 2024. All rights reserved.