ITeye博客

解决.net中使用prototype产生乱码

maybe723 · 2008-10-21 15:36 · .net · Markdown

prototype默认用utf-8的字符编码,而.net中用gb2312,所以进行转换 

 

    public String ConvertContent(String content)
    {

        Encoding utf8 = Encoding.UTF8;
        Encoding gb2312 = Encoding.GetEncoding("GB2312");
        //转为utf-8格式  
        byte[] u = gb2312.GetBytes(content);
        byte[] g = Encoding.Convert(utf8, gb2312, u);
        string sutf8 = gb2312.GetString(g);
        return sutf8;
    }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。