【问题标题】:C# and character decodingC# 和字符解码
【发布时间】:2011-01-27 05:35:57
【问题描述】:

我有一个字符串 \u0025A3\u0025A3... 等等。那么如何在 C# 中将其解码为普通视图。

我的意思是序列 \u0025A3\u0025A3 应该在解码模式下查看。例如,\u0025A3\u0025A3 序列应该看起来像“::”。

谢谢。

【问题讨论】:

标签: c# string decode


【解决方案1】:

您可以使用split 方法来解码您的字符串。

【讨论】:

    【解决方案2】:

    字符串中的 Unicode 字符高于 \uFFFF,因此它们将显示为“?”在默认的 Windows 字符集中,或在某些应用程序中使用“?”。无论如何都要试试这个。

    string test = "\\u0025A3\\u0025A3";
    Regex rx = new Regex(@"\\[uU]([0-9A-F]{6})");
    test = rx.Replace(test, match => char.ConvertFromUtf32(int.Parse(match.ToString().Substring(2), NumberStyles.HexNumber)));
    

    【讨论】:

      猜你喜欢
      • 2019-04-01
      • 2017-11-01
      • 2014-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多