2
我正在使用System.Text.Encoding
的1252編碼擴展ASCII支持以充分利用字節的第8位,到目前爲止,當使用Mono作爲Scripting Backend
時,我將能夠阻止代碼的剝離通過Assets/link.xml
文件是這樣的:如何防止Unity3d中託管dll的剝離IL2CPP
<assembly fullname="I18N">
<type fullname="I18N.Common" preserve="all"/>
<type fullname="I18N.Common.ByteEncoding" preserve="all"/>
<type fullname="I18N.Common.Handlers" preserve="all"/>
<type fullname="I18N.Common.Manager" preserve="all"/>
<type fullname="I18N.Common.MonoEncoder" preserve="all"/>
<type fullname="I18N.Common.MonoEncoding" preserve="all"/>
<type fullname="I18N.Common.Strings" preserve="all"/>
</assembly>
<assembly fullname="I18N.West">
<type fullname="I18N.West" preserve="all"/>
<type fullname="I18N.West.ENCwindows_1252" preserve="all"/>
<type fullname="I18N.West.CP1252" preserve="all"/>
</assembly>
然而,當我切換到IL2CPP,給我的崩潰,因爲一些功能已經構建過程中剝離。即使我有統一的播放器設置禁用Stripping Level
..
這裏是我的運行時崩潰日誌:
IL2CPP崩潰:
NotSupportedException: CodePage 1252 not supported
at System.Security.Cryptography.TripleDESCryptoServiceProvider.CreateEncryptor (System.Byte[] rgbKey, System.Byte[] rgbIV) [0x00000] in <filename unknown>:0
at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0
這是相同的單聲道,當我刪除preserve
聲明中link.xml:
NotSupportedException: CodePage 1252 not supported
at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0
這裏是我使用有問題的代碼:
byte[] bytes = System.Text.Encoding.GetEncoding(1252).GetBytes(str); // exactly 8-bit
string str = System.Text.Encoding.GetEncoding(1252).GetString(bytes);
非常感謝您提前!