我的 C# 应用程序中的 Unicode 字符串显示为问号
我在 C++/CLI 项目中有一个头文件,其中包含一些不同语言的字符串。 阿拉伯语、英语、德语、中文、法语、日语等...
我有第二个用 C# 编写的项目。 这里我访问存储在 C++/CLI 项目头文件中的字符串。
头文件的编码是 Unicode - Codepage 1200 或 UTF-8。 Visual Studio 编辑器能够正确显示字符串。 在运行时,我访问这些字符串并将它们分配给本地字符串变量。 在这里我发现许多字符串没有正确显示。我是否分配它们并不重要。访问原始位置(在调试时)会向我显示所有带问号的外来字符串。尤其是中文,只是问号。
示例:“So?e St?ange ?ext in Ch?n?se” (我知道这不是最好的例子)
问题出在哪里? 我读到 C# 默认是 UTF-16, 我的包含字符串的头文件是 UTF-16 或 UTF-8。
我必须能够处理不同语言的字符串。我做错了什么?
I have a header file in C++/CLI project, which contains some strings in different languages.
arabic, english, german, chinese, french, japanese etc...
I have a second project written in C#.
Here I access the strings stored in the header file of the C++/CLI project.
The encoding of the header file is Unicode - Codepage 1200 or UTF-8.
the visual studio editor is able to display the strings correctly.
At runtime I access these strings and assign them into a local String variable.
Here I recognized that many strings are not shown correctly. Doesn't matter if I assign them or not. Accessing the original place (while debugging) shows me all the foreign strings with question marks. Especially chinese, just question marks.
Example : "So?e St?ange ?ext in Ch?n?se"
(This is not the best example, I know)
What is the problem?
I read that C# is by default UTF-16,
My header file containing the strings is UTF-16 or UTF-8.
I must be able to handle strings in different languages. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“?”意味着文本被读取为 Unicode(UTF16),并且在某种程度上存在到您当前代码页的转换。由于您当前的代码页不是中文,因此中文字符将转换为“?”
查看代码会很有帮助。
The '?" means that the text is read as Unicode(UTF16) and somehwere there is a conversion to your current code page. Since your current codepage is NOT chinese the chinese chararcters will get transformed to '?'
It would be helpful to see the code.