ASP because it is an ancient language, some of its functions for UTF-8 support is very poor.
For example, you want to generate a file in UTF-8 format, using commonly used scrīpting. FileSystemObject object is no good.
Scripting. The FileSystemObject object creates a file function, which is the following:
Filesystemobject.createtextfile (Filename[,overwrite[,unicode]])
The Unicode properties are described in this way:
Options available. A Boolean value that indicates whether the file is created in Unicode or ASCII file format. True If the file is created in a Unicode file format, False if the file is created in an ASCII file format. If this section is omitted, the ASCII file is assumed to be created.
We cannot use this function to create a UTF-8 format file.
At this time, we can use ADODB. Stream object, using the method see below:
Set objstream = Server.CreateObject ("ADODB. Stream ")
with Objstream
. Open
. Charset = "Utf-8"
. Position = Objstream.size
. Writetext=str
. SaveToFile Server.MapPath ("/sitemap.xml"), 2
. Close
End With
Set objstream = Nothing
with:
ASCII, Unicode, UTF-8 Introduction:
ASCII is a character set, including uppercase and lowercase letters, numbers, control characters, etc., which are expressed in one byte, and the range is 0-127.
Because of the very limited number of characters represented in ASCII, each country or region proposes its own character set on this basis, such as the widely used GB2312 in China, which provides encoding for Chinese characters, expressed in two bytes.
These character sets are incompatible, and the same number may represent different characters, causing trouble with the exchange of information.
Unicode is a character set that maps all the characters in the world to a unique number (code point), such as a digital 0x0041 corresponding to the letter A. At present, Unicode is still in development, it contains more and more characters. The
also requires a certain encoding, such as UCS-2, to represent Unicode-encoded characters in two bytes when storing characters that are represented by Unicode. And UTF-8 is another encoding of the Unicode character set, it is variable length, up to 6 bytes, less than 127 characters in a byte, and the result of the ASCII character set, which is very good compatibility, ASCII-encoded English text without modification can be used as a UTF -8 code processing, the application is very extensive.