The following is a situation where asp.net, php, jsp, and other languages need to add three bytes of content at the beginning of the output in UTF-8 output, so that the output file will not have any problems. I hope this will help you.
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 (1, 239 );
Out. write (1, 187 );
Out. write (1, 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