---
title: "解决.net中使用prototype产生乱码"
author: "maybe723"
date: "2008-10-21T15:36:31Z"
tags: []
slug: "net-prototype"
draft: false
lastmod: "2008-10-21T15:36:31Z"
id: 255889
url: "https://maybe723.iteye.com/blog/255889"
---

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;
    }
```