php输出UTF-8格式XML文件中文乱码问题(含asp,asp.net,jsp代码)_PHP_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > PHP > php输出UTF-8格式XML文件中文乱码问题(含asp,asp.net,jsp代码)

php输出UTF-8格式XML文件中文乱码问题(含asp,asp.net,jsp代码)

 2012/5/5 12:45:42  abc123456789cba  程序员俱乐部  我要评论(0)
  • 摘要:下面是asp.net,php,jsp等语言在输出utf-8是需要在输出开始添加三个字节的内容,不让输出的文件会有一定的问题,希望对大家有所帮助。UsingASP.NETC#Response.ContentType="text/xml;characterset=utf-8";Response.BinaryWrite(newbyte[]{0xEF,0xBB,0xBF});//NowwriteyourXMLdatatooutputstreamhttp://www.my400800
  • 标签:.net ASP.NET 文乱码问题 PHP 输出 文件 net 文乱码 问题 代码 乱码问题 XML文件 XML JS

下面是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??http://www.my400800.cn?
???

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

发表评论
用户名: 匿名