如何在Visual Studio 2008和C ++中显示希腊字符?

时间:2014-10-31 20:30:08

标签: c++ visual-studio-2008

如何使用普通C ++和VS 2008 Express显示希腊字符和字符串?

以下是代码:

#include <iostream>

int main()
{
    std::cout << 'Φ' << std::endl;
    std::cout << 'Ξ' << std::endl;
    std::cout << "Καλημέρα" << std::endl;

    std::cin.get();
    return 0;
}

顺便说一下,我收到如下警告

1>d:\02_visualstudio2008projects\displaygreek\displaygreek\displaygreek.cpp(5) : warning C4566: character represented by universal-character-name '\u03A6' cannot be represented in the current code page (1252)

1 个答案:

答案 0 :(得分:0)

有两种方法可以解决这个问题。

方法#1:嵌入式unicode

这对于那些拥有允许直接输入unicode字符的键盘的用户非常有用。您可以像这样定义一个变量:

char a = 'ф';

所有这些要求是源文件的编码设置为UTF-8。

方法#2:通用字符名称(UCN)

使用此方法,您可以使用\u#为UCN的编码格式#

char a = '\u0444';

找到UCN值的好地方是here

here获取的一些代码示例。