代码之家  ›  专栏  ›  技术社区  ›  sharkin

CNET-将字符代码转换为等效字符的方法

  •  1
  • sharkin  · 技术社区  · 16 年前

    "More kitchen supplies for the people"
    

    明文形式为:

    "More kitchen supplies for the people"
    

    一般来说,我可以假设常规的ascii文本,没有奇怪的unicode或奇怪的字母。看起来像'、“、|等正常符号是作为字符代码提供的。

    2 回复  |  直到 16 年前
        1
  •  8
  •   x0n    16 年前

    ps> add-type -an system.web
    ps> [system.web.httputility]::HtmlDecode(""")
    "
    ps>
    

    希望这能有所帮助,

        2
  •  0
  •   JaredPar    16 年前

    public char Convert(string data) {
      data = data.SubString(1);  // Lose the &
      var num = Int32.Parse(data, NumberStyles.Hex | NumberStyles.AllowHexSpecifier);
      var chars = Encoding.ASCII.GetChars(new byte[] { (byte)num });
      return chars[0];
    }
    
    推荐文章