StreamReader and codepage problems in standalone player
I'm currently converting an older non-Unity project to kind of future proof it. To do this I need to be able to handle the original savegames, which used a custom encryption methode to prevent savegame cheating. In order to load and decrypt that data in Unity I need to load it with the exact same character encoding as the original software produced, which I found to be Codepage 1252. UTF-8 and others don't work correctly.
The problems I am having are caused by this line:
StreamReader file = new StreamReader(filetoload, System.Text.Encoding.GetEncoding(1252));
And it works perfectly fine, my recreated decryption works (only if the codepage is exact, otherwise it returns an unusable mess). Perfectly fine in the Editor that is. When I build it, it won't go past the above line in the standalone player, giving me this message in the player.log:
NotSupportedException: Encoding 1252 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 <4756199cf52a4f14b33cdcc5659f782e>:0 at main.LoadGame () [0x0004d] in :0 at main.clicky (System.String onwhat) [0x002ee] in :0 at main.b__85_9 () [0x00000] in :0 at UnityEngine.Events.InvokableCall.Invoke () [0x00010] in <36c750e02af54ffa9140c3fe07ab177b>:0 at UnityEngine.Events.UnityEvent.Invoke () [0x00022] in <36c750e02af54ffa9140c3fe07ab177b>:0 at UnityEngine.UI.Button.Press () [0x0001c] in :0 at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00009] in :0 at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00007] in :0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x0006c] in :0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) UnityEngine.EventSystems.StandaloneInputModule:ReleaseMouse(PointerEventData, GameObject) UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() UnityEngine.EventSystems.StandaloneInputModule:Process() UnityEngine.EventSystems.EventSystem:Update()
Of course I did try to find a solution to this and - as suggested for other people who had this error - I ended up dumping the I18N.dll and I18N.West.dll into my _data/Managed folder. Didn't work, but the error (produced by the same line) now reads as follows:
InvalidProgramException: Invalid IL code in I18N.Common.Manager:get_PrimaryManager (): IL_0000: ret
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0 Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0004b] in :0 at System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) [0x00546] in :0 at System.Text.EncodingHelper.InvokeI18N (System.String name, System.Object[] args) [0x0009a] in :0 at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x0020d] in :0 at main.LoadGame () [0x0004d] in :0 at main.clicky (System.String onwhat) [0x002ee] in :0 at main.b__85_9 () [0x00000] in :0 at UnityEngine.Events.InvokableCall.Invoke () [0x00010] in :0 at UnityEngine.Events.UnityEvent.Invoke () [0x00022] in :0 at UnityEngine.UI.Button.Press () [0x0001c] in :0 at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00009] in :0 at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00007] in :0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x0006c] in :0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) UnityEngine.EventSystems.StandaloneInputModule:ReleaseMouse(PointerEventData, GameObject) UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() UnityEngine.EventSystems.StandaloneInputModule:Process() UnityEngine.EventSystems.EventSystem:Update()
I do have a vague feeling that this IL_0000 code is the problem and it might should read IL_1252, but that is a wild guess. I've also tried a lot of the other approaches from similar threats. My scripting backend is set to Mono, I also tried dumping the other I18N files into. Does anyone have a clue how I can get this thing to work outside of the editor?
Your answer
![](https://koobas.hobune.stream/wayback/20220613003300im_/https://answers.unity.com/themes/thub/images/avi.jpg)