使用波斯语名称创建向量。 C++
Create vector with Farsi names. C++
我打算用波斯语名字创建一个 std::vector<std::string>
。但是一旦我编译它,我就会得到这个错误:
这似乎是一个 unicode 问题。有什么解决方法的建议吗?
Microsoft 的 Visual C++ 编译器 does support Unicode source code files. Specifically it accepts UTF-8 (byte order mark required) or UTF-16:
Source code files
Unicode characters are now supported in identifiers, macros, string and character literals, and in comments. Universal character names are also now supported.
Unicode can be input into a source code file in the following encodings:
UTF-16 little endian with or without byte order mark (BOM)
UTF-16 big endian with or without BOM
UTF-8 with BOM
特别注意,对于UTF-8,字节顺序标记是必需的。屏幕截图中的对话框是 Visual Studio 编辑器检测到您输入了 non-ASCII 个字符并询问您是否要将源代码文件转换为 UTF-8 或 UTF-16(不确定是什么默认是,但我猜是 UTF-8)。如果单击“是”,它将使用 UTF-8 字节顺序标记 (BOM) 保存文件,一切正常。
我打算用波斯语名字创建一个 std::vector<std::string>
。但是一旦我编译它,我就会得到这个错误:
这似乎是一个 unicode 问题。有什么解决方法的建议吗?
Microsoft 的 Visual C++ 编译器 does support Unicode source code files. Specifically it accepts UTF-8 (byte order mark required) or UTF-16:
Source code files
Unicode characters are now supported in identifiers, macros, string and character literals, and in comments. Universal character names are also now supported.
Unicode can be input into a source code file in the following encodings:
UTF-16 little endian with or without byte order mark (BOM)
UTF-16 big endian with or without BOM
UTF-8 with BOM
特别注意,对于UTF-8,字节顺序标记是必需的。屏幕截图中的对话框是 Visual Studio 编辑器检测到您输入了 non-ASCII 个字符并询问您是否要将源代码文件转换为 UTF-8 或 UTF-16(不确定是什么默认是,但我猜是 UTF-8)。如果单击“是”,它将使用 UTF-8 字节顺序标记 (BOM) 保存文件,一切正常。