解决UniRx错误NotSupportedException:Encoding936datacouldnotbefound.
2019-01-25 18:12阅读:
错误如下:
E/Unity: NotSupportedException: Encoding 936 data could not be
found. Make sure you have correct international
codeset assembly installed and
enabled.
at System.Text.Encoding.GetEncoding
(System.Int32 codepage) [0x0023f] in :0
at System.Text.Encoding.GetEncoding
(System.String name) [0x00012] in :0
at
UnityEngine.Networking.DownloadHandler.GetTextEncoder () [0x00081]
in <543adeaed83640f097658e7041686823>:0
at
UnityEngine.Networking.DownloadHandler.GetText () [0x00018] in
<543adeaed83640f097658e7041686823>:0
at
UnityEngine.Networking.DownloadHandler.get_text () [0x00001] in
<543adeaed83640f097658e7041686823>:0
at UnityEngine.WWW.get_text () [0x0004f] in
:0
at UniRx.ObservableWWW+c__Iterator1.Move
Next () [0x0017f] in
<9433398a4ece42deaac607a2
4755b109>:0
at
UnityEngine.SetupCoroutine.InvokeMoveNext
(System.Collections.IEnumerator enumerator, System.IntPtr
returnValueAddress) [0x00027] i
看错误是字符编码的问题,解决方案分析:
最近在开发中要用到GB2312字符编码(
CP936),在C#代码中便有了如此代码
1
System.Text.Encoding.GetEncoding(
936)
这在Unity3d
编辑器下运行没有任何问题,打包出exe文件执行时,便会出现程序无响应的情况,查看日志文件可以看到如下错误:
NotSupportedException: CodePage 936 not supported
谷歌后...便将
I18N.DLL 和
I18N.CJK.DLL
从Unity安装目录(
Editor\Data\Mono\lib\mono\unity 和
Editor\Data\Mono\lib\mono\2.0
两个目录下都存在,PC上测试均可使用)拷贝到项目目录的Assets目录下,然后重新编译出包,正常运行。
在打包出iOS包时,又再次出现
NotSupportedException: CodePage 936 not
supported。前面虽然已经把相关库文件放到项目之中,但仔细查看xcode工程目录,其下并没有I18N.DLL 和
I18N.CJK.DLL 文件的任何影子。此时便想到我们的unity项目中使用的
stripping
level可能会有影响,索性暂时disable
stripping,尝试重新出iOS包,发现一切正常,再看xcode工程目录下果然也有了I18N.DLL 和
I18N.CJK.DLL。
那么,问题又来了,如果仍想继续使用stripping,有没有办法?
unity 官方手册(
http://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html)中提到,可以通过添加白名单的方式,在使用stripping时,忽略掉指定的库。方式是在Assets根目录下添加link.xml文件,其内容格式如下
最近在开发中要用到GB2312字符编码(
CP936),在C#代码中便有了如此代码
1
System.Text.Encoding.GetEncoding(
936)
这在Unity3d
编辑器下运行没有任何问题,打包出exe文件执行时,便会出现程序无响应的情况,查看日志文件可以看到如下错误:
NotSupportedException: CodePage 936 not supported
谷歌后...便将
I18N.DLL 和
I18N.CJK.DLL
从Unity安装目录(
Editor\Data\Mono\lib\mono\unity 和
Editor\Data\Mono\lib\mono\2.0
两个目录下都存在,PC上测试均可使用)拷贝到项目目录的Assets目录下,然后重新编译出包,正常运行。
在出iOS包时,又再次出现
NotSupportedException:
CodePage 936 not
supported。前面虽然已经把相关库文件放到项目之中,但仔细查看xcode工程目录,其下并没有I18N.DLL 和
I18N.CJK.DLL 文件的任何影子。此时便想到我们的unity项目中使用的
stripping
level可能会有影响,索性暂时disable
stripping,尝试重新出iOS包,发现一切正常,再看xcode工程目录下果然也有了I18N.DLL 和
I18N.CJK.DLL。
那么,问题又来了,如果仍想继续使用stripping,有没有办法?
unity 官方手册(
http://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html)中提到,可以通过添加白名单的方式,在使用stripping时,忽略掉指定的库。方式是在Assets根目录下添加link.xml文件,其内容格式如下
使用CP936,只需要添加上述内容。
如此,将该link.xml文件添加到Assets根目录下后,开启stripping后,CP936也可以正常使用了~
文章来自: https://www.cnblogs.com/cqgreen/p/4101599.html