单声道和传递unicode字符串
mono and passing on unicode strings
我在我的应用程序中嵌入mono,但我有mono的字符串转换问题。
c++代码:static inline void p_Print(MonoString *str) {
cout << "UTF8: " << mono_string_to_utf8(str) << endl;
wcout << "UTF16: " << ((wchar_t*)mono_string_to_utf16(str)) << endl;
}
//...
mono_add_internal_call("SampSharp.GameMode.Natives.Native::Print", (void *)p_Print);
c#代码:[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void Print(string msg);
//...
Print("characters like u00D6 are working? (should be an O with " above it)");
输出:UTF8: characters like ├û are working? (should be an O with " above it)
UTF16: characters like Í are working? (should be an O with " above it)
正如您所看到的,输出不完全是它应该打印的,它应该打印"像Ö这样的字符正在工作?"(应该是一个带有" above it "的O)",但是mono_string_to_utf8和_to_utf16都没有做它应该做的事情。
如何解决这个问题?
解决方法如下:
string mono_string_to_string(MonoString *str)
{
mono_unichar2 *chl = mono_string_chars(str);
string out("");
for (int i = 0; i < mono_string_length(str); i++) {
out += chl[i];
}
return out;
}
可能不是最漂亮的方式,但它有效。
相关文章:
- 如何将unicode字符串从C++传递到delphi
- 将 unicode 字符串与 c ++ 符号进行比较?
- C++:Unicode 字符串文字的可移植性
- 如何使用 CTypes 将 wchar_t** - 以空结尾的 UNICODE 字符串数组 - 返回到 Python 脚
- Xamarin Android:在 C++ 中将字符串从 C# 封送到 Unicode 字符串的正确方法是什么?
- 如何在 python 包装中使用 unicode 字符串用于带有 cython 的 c++ 类?
- 如何使用poco :: logger记录Unicode字符串
- 如何将 Unicode 字符串连接成字符串以传递到 mysql 调用中
- Unicode字符串Visual C 构造函数
- 如何将 (ICU4C) Unicode 字符串逐个字符复制到另一个 Unicode 字符串
- 如何从Windows中的进程中读取Unicode字符串
- 如何在Visual C 中的BSTR和32位Unicode字符串之间进行转换
- C 编译器如何从UTF8源文件中生成Unicode字符串文字
- 如何检测终端中的unicode字符串宽度
- 如何在字符级别操作Unicode字符串
- 获取Crypto++中Unicode字符串的SHA1
- 将 unicode 字符串转换为字符串
- c++Unicode字符串与易混淆字符的比较.例如(U 0054)应为==(U03A4)等
- 如何在带L(或不带L)的变量中传递unicode字符串
- C++中的Unicode字符串处理