用C#该如何解码?谢谢

解决方案 »

  1.   

    因为使用utf-8,这个utf经常不小心就乱码
    在vs.net里把html代码拷贝,然后关闭这页,然后在这个文件上右键,选择打开方式,选择utf-8带编码的方式打开
    然后把拷贝的东西粘贴
    就显示中文了
      

  2.   

    楼上的大哥,我想在一个string变量里面把utf-8的东东换成gb2312的本来面目,请问如何操作
      

  3.   

    private string Unicode2GB(string unicodeString)
    { // Create two different encodings.
    Encoding gb = Encoding.GetEncoding("GB2312");
    Encoding unicode = Encoding.Unicode; // Convert the string into a byte[].
    byte[] unicodeBytes = unicode.GetBytes(unicodeString); // Perform the conversion from one encoding to the other.
    byte[] gbBytes = Encoding.Convert(unicode, gb, unicodeBytes);
                
    char[] gbChars = new char[gb.GetCharCount(gbBytes, 0, gbBytes.Length)];
    gb.GetChars(asciiBytes, 0, gbBytes.Length, gbChars, 0);
    string gbString = new string(gbChars);
    return gbString;
    }
      

  4.   

    System.Web.HttpUtility.HtmlDecode("成都");
      

  5.   

    经过实际测试,sykpboy(小憩---每天解决1个问题,顺便升星) 兄的方法调试通过,但是并没能成功转换;alien54155415() 兄的方法只有1句,确OK了,再请教下是什么原因呢
      

  6.   

    那個是被html编码过的汉字,类似的url里面有汉字,就会被编码传输