- Home /
XMLSerializer Encoding Issue
While trying to load in a xml script, im getting this error in the output_log
ArgumentException: Encoding name 'Windows-1252' not supported
Parameter name: name
at System.Text.Encoding.GetEncoding (System.String name) [0x00000] in <filename unknown>:0
at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream) [0x00000] in <filename unknown>:0
at System.Xml.XmlInputStream..ctor (System.IO.Stream stream) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Xml.XmlInputStream:.ctor (System.IO.Stream)
at System.Xml.XmlStreamReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Xml.XmlStreamReader:.ctor (System.IO.Stream)
at System.Xml.XmlTextReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0
at System.Xml.Serialization.XmlSerializer.Deserialize (System.IO.Stream stream) [0x00000] in <filename unknown>:0
at ComboManager.GetCombo (System.String _name) [0x0008d] in C:\Users\Admin\Desktop\Battle Brawl\Assets\Battle Assets\Scripts\Managers\ComboManager.cs:25
at Grenadier.Start () [0x00000] in C:\Users\Admin\Desktop\Battle Brawl\Assets\Battle Assets\Scripts\CharacterArchetypes\Grenadier.cs:7
(Filename: C Line: 0)
This is only happens when i build my game, and not in the editor.
Anybody know a fix?
Answer by rutter · Mar 24, 2012 at 11:24 PM
This thread seems to have more information, and a potential workaround.
This next option isn't a sure bet, but you could try it: check your player settings, and if your API compatibility level is ".Net 2.0 subset", try bumping it up to ".Net 2.0". Doing so can increase the size of your built player, and unfortunately won't work on some of the more esoteric platforms, but it could provide a quick resolution.
Thanks the answer in the link helped me out.
Just moved "I18N.dll" and "I18N-West.dll" into my managed folder for the build and it all worked fine, thanks :)
Answer by lizardboy79 · Apr 07, 2015 at 09:38 PM
Hey all,
there is a much better solution than copying DLLs. When you do your serialization, make sure to use a Streamwriter with encoding set to "UTF-8" rather than a FileStream. Like this:
var serializer = new XmlSerializer(typeof(SerializableClass));
string filename = Application.dataPath + outputpath + outPutFileName;
var encoding = Encoding.GetEncoding("UTF-8");
using(StreamWriter stream = new StreamWriter( filename, false, encoding))
{
serializer.Serialize(stream, this);
}
Cheers!
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Trying to XML serialize objects, getting error that UnityEngine.Transform doesn't implement Add() 1 Answer
Windows Application 2 Answers
A node in a childnode? 1 Answer
Is there any plugin for image tracking in windows ?Or does anyone knows how to do it in windows ? 0 Answers