unity3d使用litjson中文显示的问题

  我们在使用litjson时它的编码方式是unicode的,所以我将json转成string输出时显示的是unicode的编码。这样我们显示或者保存中文时不是很方便。我们可以将中文的unicode转成能识别的GBK编码。

 using UnityEngine;
using System.Collections.Generic;
using Utils;
using LitJson;
using System;
using System.Text.RegularExpressions; public class Script1 : MonoBehaviour
{
public void OnTestJson()
{
JsonData sData = new JsonData();
JsonData data1 = new JsonData();
JsonData data2 = new JsonData(); data1["等级"] = "";
data1["位置"] = "m=1000,x=33,y=21"; //新手村 data2["等级"] = "";
data2["位置"] = "m=1001,x=58,y=97"; //桃园镇 sData["张三"] = data1;
sData["李四"] = data2; string jsonStr = sData.ToJson(); Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
var ss = reg.Replace(jsonStr, delegate(Match m) { return ((char)Convert.ToInt32(m.Groups[].Value, )).ToString(); }); print(ss);
}
}

显示如下

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAl8AAAAyCAIAAADtKCnnAAAaA0lEQVR4nO1d+VsTSfrPf7E/fX/Y2R2fYceZ2R3HdWDWiMYBDxB0QGAcDXcgAq54AOIxXus1CINDBwwJkHAjJMEWRBEQRA5BBOUYUE4R5M4BCYHQ3x967Gm6O50OAUSsz/N5eIq3q956q+p9u9Ld1dWs/ywL1q5dS5DY29vvX9lY+RYuClZZM+3t7ZfHpQEAAFY3WN8tC9auXUuQ2Nvb/7SysfItXBSssmba29svj0sDAACsbrBslgWff/45QWJnZ7dvZWPlW7goWGXNtLOzWx6XBgAAWN1gWZsCDMMm85iElZUVQcLhcDwWChiGCYmlAHMLl9SMpbbBkoFYgeBwOJa7KwAAAADrWxz4fH5SUpJMJktOTj569CgqhGH4W4thZWVFkHA4HHcSTp06lZqaKpfL09LSLl68SM6AAoZhQmIpwNzCJTWDDBiGYRiWy+Uikcjf399CG8jNhOfDIlvn6yTYvBTgcDiWuysAAAAA69/vwOfzRSKRs7OzjY2No6NjVFQUKodh+N8Ww8rKiiDhcDiu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fHkpqXKYq6nXzRnkMp+I/Y0UwSmKSivlMsq0W3rkbv1xmrhT7nTr4oRVGHfUud0iRKtUqNzvd0zvaAxJ+he/gMibk1Q6PqmznVDC0ZHtOEXb+zPSAxKuUhk4ajaXTr4azCZ0WVv1MWoe95/Lg/fjbvuWNETAG6KsfO/49VOWcF97HiHsfT7PxuZhQ04D8cQT+g9x63XxWXfe930zVUcvdRG9nrDl1WELZpBgQEBKSbHc2iw0Hxg+oOpUan1OjuV7VjD9LoZ8fIXwuVaq3y3XUMeWtaZD5odHpGZnW+HtVMTd8pb8VulNEX2RWUVFzdodToegbG8a9VMJkkXEMl6AdXn7a8xj5RSVmLsZwotDp9ae3L3YeSaUyiVHshoVip1irV2vSCBnyGvUekBsOcC+6rmfSWnIXuoZ8pF8tqmc+ObV1D2umZ6sYeY/fA6XseP+6/pVfi16yycW90vB6cuCIqxeQGw1zLq7fa6Zmapj/r3eRpYkAd+KL7Ve1Kje714ERU8kOy1+UUNV5IKF6Y2wMCAq5WLtrsuCi0fGtaW08BfpUj4FKQ/r6ruXQ4KB6dmHQw9TUZY+Sfz8Pu7i6kdr4IvO8ICAhI5gqaHS3fmnZ4XDMza3jVN4ItSAFcCi7u7MjmQvHZVQ8Y7JVDpmZqWqXRod/cWRiLq9qZ7EcMCAj4sXEFzY6AgICAgIArhGB2BAQEBAQEJBLMjoCAgICAgESyNgAAAAAAAADMB5gdAQAAAAAAiPh/OcQILznQPW0AAAAASUVORK5CYII=" alt="" />

转载请注明出处http://www.cnblogs.com/fyluyg/p/5963052.html

上一篇:Struts2中使用Session的两种方法


下一篇:安装lnmp(linux nginx mysql php)