unicode转中文 C# (dotnetcore)

版权声明:版权声明:本文为博主原创文章,转载请附上博文链接! https://blog.csdn.net/qq_36051316/article/details/84390139

unicode转中文 C#

unicode转中文 (dotnetcore)

需要引用:using System.Text.RegularExpressions;

使用语言:C#

环境:.net core 2.1 (当前使用)

核心方法:
Regex.Unescape();

核心代码:

string str1 = "\u9759\u6b62\u7684";
string strCov = Regex.Unescape(str1);
System.Console.WriteLine(strCov);

运行转中文的结果
全部代码:

using System;
using System.Text.RegularExpressions;
namespace netcore.regex_unescape.demo
{
    class Program
    {
        static void Main(string[] args)
        {
            //using System.Text.RegularExpressions;
            // 我们需要使用Regex 来转换他们,unescape这个方法可以把unicode转中文
            string str1 = "\u9759\u6b62\u7684";
            string strCov = Regex.Unescape(str1);
            System.Console.WriteLine(strCov);
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_36051316/article/details/84390139
今日推荐