简体   繁体   English

将unicode字符从本机转换为Java时出现问题

[英]problem converting unicode characters from native to Java

I have a JNI code written in Objective-C (though I believe I would have the same problem in a C/C++ program) that returns jstring to the Java code. 我有一个用Objective-C编写的JNI代码(尽管我相信在C / C ++程序中会遇到同样的问题),该代码将jstring返回到Java代码。 I am using the char* to jstring conversion as specified here in the "Creating Java Strings From Native Strings" section. 我使用的char *为指定的jstring转换这里的“创建Java字符串从本地字符串”部分。 My problem is that while on the native side the strings are correct (ie native string presents in the standard output correctly) when passed to Java and sent to standard output I get '?' 我的问题是,虽然在本机端,当传递给Java并发送到标准输出时,字符串是正确的(即,本机字符串正确地出现在标准输出中),但是我得到了'?' for the non-English characters. 非英语字符。

Thanks 谢谢

Java字符串是UTF-16编码的,您需要考虑字节序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM