Encoding.GetEncoding("gb2312").GetBytes(str).Length;
1.在Unity软件目录中搜索:I18N.dll和I18N.CJK.dll。会搜索到多个,任意一个都行。 2.把上面搜索到的2个dll文件复制到Asset目录下。 3.OK了。
在unity编辑器里面运行没问题,运行build版报“ArgumentException: Encoding name 'gb2312' not supported”,解决如下:
The issue here is that I18N.dll and I18N.West.dll are missing in the standalone player. They are available in the editor, though. That's why it's working in the editor but not in the standalone player.
Solution: Put those DLLs into your project (probably best next to System.Data.dll), that way, they will be also available in the standalone player.
NOTE: There's also other I18N ("Internationalization") DLLs available, so if you have trouble with another CodePage, you might have to use one of those in your specific case.
I18N.dll和I18N.CJK.dll
即,将unity安装目录下的两个dll复制到工程文件下,和System.Data.dll同级即可,然后再build。