Ⅰ gb2312的汉字怎么转换成utf-8的汉字
如果你就是要转文字编码,那么打开一个编辑器,复制好内容,在新建好的文件(你要的编码)中粘贴就可以了。
如果你是编程中要用代码转换的,一般的开发语言都提供了编码转换的类或函数。
Ⅱ 怎么把gb2312转成utf8
如果只有一两个文件,用记事本打开UTF8文件,然后保存,保存时点击“保存选项”按钮,选择文件格式为ANSI,在中文Windows环境下,这个新文件就是GB2312格式的了。
Ⅲ C语言UTF8要怎样转gb2312
一、这个转换关键要有码表,而不是什么语言。UTF-8不一定总能转换成GB2312、GBK、GB-18030等。GB2312实际上是UTF-8(Unicode的一种形式)的一个子集。
常用的基本方式有两个类别:
1、iconv,这个是通用的,具体的看手册
2、Windows的WideCharToMultiByte、MultiByteToWideChar。WideChar就是Unicode(UTF-16),UTF-8、GB2312等同属于MultiByte,先要将UTF-8变成WideChar,然后将WideChar再变成GB2312。
二、如果只有一两个文件,用记事本打开UTF8文件,然后保存,保存时点击“保存选项”按钮,选择文件格式为ANSI,在中文Windows环境下,这个新文件就是GB2312格式的了。
Ⅳ C# GB2312转UTF8
比如实现Utf-8和GB2312的转换:
string gb2312info = "你好!";
string utfinfo = string.Empty;
Encoding utf8 = Encoding.UTF8;
Encoding gb2312 = Encoding.GetEncoding("gb2312");
// Convert the string into a byte[].
byte[] unicodeBytes = gb2312 .GetBytes(gb2312info );
// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(gb2312,utf8, unicodeBytes);
// Convert the new byte[] into a char[] and then into a string.
// This is a slightly different approach to converting to illustrate
// the use of GetCharCount/GetChars.
char[] asciiChars = new char[utf8 .GetCharCount(asciiBytes, 0, asciiBytes.Length)];
utf8 .GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
utfinfo = new string(asciiChars);
Ⅳ 如何将C#程序由gb2312编码转换成utf-8编码
用.txt文本打开,文件(F)选另存为,编码选utf8.
Ⅵ 谁有GB2312转换成UTF-8的c代码
void GB2312ToUTF_8(string& pOut,char *pText, int pLen)
{
char buf[4];
char* rst = new char[pLen + (pLen >> 2) + 2];
memset(buf,0,4);
memset(rst,0,pLen + (pLen >> 2) + 2);
int i = 0;
int j = 0;
while(i < pLen)
{
//如果是英文直接复制就可以
if( *(pText + i) >= 0)
{
rst[j++] = pText[i++];
}
else
{
WCHAR pbuffer;
Gb2312ToUnicode(&pbuffer,pText+i);
UnicodeToUTF_8(buf,&pbuffer);
unsigned short int tmp = 0;
tmp = rst[j] = buf[0];
tmp = rst[j+1] = buf[1];
tmp = rst[j+2] = buf[2];
j += 3;
i += 2;
}
}
rst[j] = ''\0'';
//返回结果
pOut = rst;
delete []rst;
return;
}
Ⅶ 怎样将gb2312编码的字符串转换为utf-8编码的字符串
Java中字符串转码,根据实际运用的环境有以下三种方式
- 使用Java.lang.String这是最常用的方法,先用对应编码获取字节,然后重新构造新编码,示例代码如下:
Strings="清山";
byte[]b=s.getBytes("utf-8");//编码
Stringsa=newString(b,"gb2312");//解码:用什么字符集编码就用什么字符集解码 - java.io.InputStreamReader/OutputStreamWriter:桥转换读写文件的应用中,可以使用这种方式,直接在IO流构造中转换,示例代码如下:
InputStreamis=newFileInputStream("C:/项目进度跟踪.txt");//文件读取
InputStreamReaderisr=newInputStreamReader(is,"utf-8");//解码
OutputStreamos=newFileOutputStream("C:/项目进度跟踪_gb2312.txt");//文件输出
OutputStreamWriterosw=newOutputStreamWriter(os,"gb2312");//开始编码 - java.nio.Charset使用nio中的Charset转换字符,示例代码如下:
CharsetinSet=Charset.forName("utf-8");//解码字符集
CharsetoutSet=Charset.forName("gb2312");//编码字符集
CharsetDecoderde=inSet.newDecoder();//解码器
CharsetEncoderen=outSet.newEncoder();//编码
Ⅷ 如何将gb2312编码转换到utf-8网页编码
UTF-8是UTF-8编码是一种目前广泛应用于网页的编码,它其实是一种Unicode编码,即致... 需要使用UTF-8,那么怎么把gb2312编码转换到utf-8编码呢?在dreamweaver里只需要一
Ⅸ 弱弱的问一句,C语言能不能实现字符串的编码格式转换 GB2312toUTF-8
其实 linux 和 windows 的系统函数都是C函数,并且提供了GB2312toUTF-8的函数,所以C语言是可以实现转码的。以下是windows的例子:int num = ::MultiByteToWideChar(CP_ACP, 0, "你好", -1, NULL, 0);wchar_t* m_arrayShort = new wchar_t[num];::MultiByteToWideChar(CP_ACP, 0, "你好", -1, m_arrayShort, num); int len = ::WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR)m_arrayShort, num, 0, 0, NULL, NULL);char *tmpPT = new char[len+1];::WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)m_arrayShort, num, tmpPT, len, NULL, NULL);tmpPT[len] = 0;
Ⅹ 如何将gb2312转换成utf-8拜托各位大神
这是一个关于网页乱码的问题
如果你提交到服务器的是一个中文这时你的转换这个字符
网上有很多关于过滤器的代码
你也可以用
new
String("字符串".setbey("ISO-8859-1"),"UTF-8");
方法来转换,因为网页默认的是ISO-8858-1
你可以试试不行再找别的答案
我一般都是这么用
我是放在web.xml配置文件里的先写好一个selevt在加到web.xml中当你提交时他会先去转换在提交