Unity3d LitJson中文乱码问题

string mainPath = Application.streamingAssetsPath + "/main.txt";
string mainJson = JsonMapper.ToJson(m_ListMainObj);

Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
mainJson = reg.Replace(mainJson, delegate (Match m) {
    
     return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });

using(FileStream fs = File.Open(mainPath, FileMode.OpenOrCreate))
{
    
    
    // Putting some contents
    Byte[] info = new UTF8Encoding(true).GetBytes(mainJson);
    fs.Write(info, 0, info.Length);
}

猜你喜欢

转载自blog.csdn.net/weixin_41743629/article/details/130963564