我想读取名字“AnnaHäuser”并保存到文件中,但问题是这不是编码,而是转换为“AnnaH user”,我该怎么做?
我正在使用此代码进行编码:
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<getData> getData = new List<getData>();
getData.Add(new getData { imagename = "Picture1", date = "03.02.2014", customernumber = 9, name = "Anna Häuser" });
var jobject = getData;
string str = serializer.Serialize(jobject);
string utf8String = str ;
string propEncodeString = string.Empty;
byte[] utf8_Bytes = new byte[utf8String.Length];
for (int i = 0; i < utf8String.Length; ++i)
{
utf8_Bytes[i] = (byte)utf8String[i];
}
propEncodeString = Encoding.UTF8.GetString(utf8_Bytes, 0, utf8_Bytes.Length);
string outputpath = @"C:\ResizeImages\ResizeImages\jsondataoutput.txt";
System.IO.File.WriteAllText(outputpath, propEncodeString, Encoding.Unicode);