程序输出urf-8编码的xml文件中文(汉字)乱码问题解决方法
2011-11-15 16:26
549 查看
asp.net,php,jsp等语言在输出utf-8是需要在输出开始添加三个字节的内容,不让输出的文件会有一定的问题,希望对大家有所帮助。
Using ASP.NET C#
Response.ContentType="text/xml; characterset=utf-8" ;
Response.BinaryWrite( new byte[]{0xEF,0xBB,0xBF} );
// Now write your XML data to output stream
Using ASP.NET VB
Response.ContentType="text/xml"
Dim UTFHeader() As Byte ={&HEF,&HBB,&HBF}
Response.BinaryWrite(UTFHeader)
' Now write your XML data to output stream
Using PHP
header ( 'Content-type: text/xml' );
echo pack ( "C3" , 0xef, 0xbb, 0xbf );
// Now write your XML data to output stream
Using ASP
Response.ContentType="text/html"
Response.AddHeader"Content-Type","text/html;charset=UTF-8"
Response.CodePage=65001
Response.CharSet="UTF-8"
Response.BinaryWrite( chrb(239) )
Response.BinaryWrite( chrb(187) )
Response.BinaryWrite( chrb(191) )
' Now write your XML data to output stream
Using JSP
response.setContentType( "text/xml; charset=UTF-8" );
OutputStream outs = response.getOutputStream();
outs.write( new byte[]{(byte)0xEF,(byte)0xBB,(byte)0xBF} );
outs.flush();
// Now write your XML data to output stream
Using ColdFusion
context = getPageContext();
response = context.getResponse().getResponse();
out= response.getOutputStream();
out.write(239);
out.write(187);
out.write(191);
// Now write your XML data to output stream
Using ROR
utf8_arr = [0xEF,0xBB,0xBF]
utf8_str = utf8_arr.pack("c3")
# Now write your XML data to output stream
Using ASP.NET C#
Response.ContentType="text/xml; characterset=utf-8" ;
Response.BinaryWrite( new byte[]{0xEF,0xBB,0xBF} );
// Now write your XML data to output stream
Using ASP.NET VB
Response.ContentType="text/xml"
Dim UTFHeader() As Byte ={&HEF,&HBB,&HBF}
Response.BinaryWrite(UTFHeader)
' Now write your XML data to output stream
Using PHP
header ( 'Content-type: text/xml' );
echo pack ( "C3" , 0xef, 0xbb, 0xbf );
// Now write your XML data to output stream
Using ASP
Response.ContentType="text/html"
Response.AddHeader"Content-Type","text/html;charset=UTF-8"
Response.CodePage=65001
Response.CharSet="UTF-8"
Response.BinaryWrite( chrb(239) )
Response.BinaryWrite( chrb(187) )
Response.BinaryWrite( chrb(191) )
' Now write your XML data to output stream
Using JSP
response.setContentType( "text/xml; charset=UTF-8" );
OutputStream outs = response.getOutputStream();
outs.write( new byte[]{(byte)0xEF,(byte)0xBB,(byte)0xBF} );
outs.flush();
// Now write your XML data to output stream
Using ColdFusion
context = getPageContext();
response = context.getResponse().getResponse();
out= response.getOutputStream();
out.write(239);
out.write(187);
out.write(191);
// Now write your XML data to output stream
Using ROR
utf8_arr = [0xEF,0xBB,0xBF]
utf8_str = utf8_arr.pack("c3")
# Now write your XML data to output stream
相关文章推荐
- qt creator修改程序编码(解决中文乱码问题)的方法
- qt creator修改程序编码(解决中文乱码问题)的方法
- 中文乱码--MySQL5.0中文问题及JDBC数据库连接和JSP汉字编码问题解决方法总
- QT学习——qt creator修改程序编码(解决中文乱码问题)的方法
- qt creator修改程序编码(解决中文乱码问题)的方法
- MySQL5.0中文问题及JDBC数据库连接和JSP汉字编码问题解决方法总结
- mysql导入导出数据中文乱码解决方法小结(1、navicat导入问题已解决,创建连接后修改连接属性,选择高级->将使用Mysql字符集复选框去掉,下拉框选择GBK->导入sql文件OK;2、phpmyadmin显示乱码的问题也解决,两步:1.将sql文件以utf8的字符集编码另存,2.将文件中sql语句中的字段字符集编码改成utf8,导入OK)
- redhat7中Codeblocks编译c程序乱码问题 中文乱码解决方法
- 关于Android Logcat打印输出中文乱码问题的解决方法
- 对Java程序中的中文乱码问题的解决方法
- 解决 iOS NSDictionary 输出中文字符”乱码”(Unicode编码)问题
- 解决servlet中输出中文到浏览器以及post、get两种提交方法乱码问题
- C++ 控制台程序中输出UTF8字符乱码问题解决方法
- MySQL5.0中文问题及JDBC数据库连接和JSP汉字编码问题解决方法总结
- 中文乱码问题 ? 原因:JSP中默认使用iso-8859-1字符编码方式,不支持中文 ? 常见的支持中文的编码方式:gb2312(常用简体汉字)、gbk(简体和繁体汉字)、utf-8 ? 解决中文乱码
- JSP页面编码问题研究三(中文字符乱码问题的解决方法)
- VC轻松解析XML文件--CMarkup使用方法(解决解析中文字符出现乱码问题)
- 深入Java中文编码乱码问题及最优解决方法
- MySQL5.0中文问题及JSP汉字编码问题解决方法
- VC轻松解析XML文件--CMarkup使用方法(解决解析中文字符出现乱码问题)