using System;
using System.Text.RegularExpressions;
string jsonString = "{\"name\":\"Hello\\u4E2D\\u6587\"}";
string decodedString = Regex.Replace(jsonString, @"\\u(?<Value>[a-zA-Z0-9]{4})", m =>
{
var hexValue = m.Groups["Value"].Value;
var unicodeValue = Convert.ToInt32(hexValue, 16);
return char.ConvertFromUtf32(unicodeValue);
});
Console.WriteLine(decodedString); // 输出: {"name":"Hello中文"}
.NET core 将JSON字符串中被转义的中文字符转回中文
最新推荐文章于 2024-05-02 13:16:25 发布