-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Unity]字符串中间含\0传递到js会被截断 #1732
Comments
il2cpp pinvoke本身也有同样的bug,如果要修正,原生接口将不能直接声明为string,而是传byte[]和长度,这样会多一个Encoding.UTF8.GetBytes调用,增加一个byte[]数组的分配和gc 考虑到unity本身也有类似的bug,之前也甚少项目反馈这问题,所以本issue的修改先不合入到master,先放到这个分支:https://github.com/Tencent/puerts/commits/fix_null_terminator_inside_string_being_cut |
如果 \0 不截断是不是也会有问题。。有遇到base64 的string末尾多几个字符以及在linux下读取js文件多几个字符的情况,都是加\0后得以解决的。 |
通过长度识别结尾 |
detail | 详细描述
现在plugin api传递字符串是没传长度的,比如返回值:
puerts/unity/Assets/core/upm/Runtime/Src/Default/Native/PuertsDLL.cs
Line 304 in 81b0f39
但utf8,utf16编码都支持中间含\0,c#编码类型api调用可能会被截断:#20
The text was updated successfully, but these errors were encountered: