Note: The ASP mentioned here
ASP supports UTF-8 because of some functions.
For example, you want to generate a file in UTF-8 format, and it is not possible to use the commonly used scripting.filesystemObject object.
Scripting.FileSystemObject The function of creating files is the following way:
FilesystemObject.createtextFile (Filename [, OverWrite [, Unicode]])
The unicode attribute is described like this:
Options. Boolean value indicates whether to create files in the Unicode or ASCII file format. If the file is created in the unicode file format, the value is true; if the file is created in the ASCII file format, the value is false. If this part is omitted, it is assumed that the ASCII file is created.
We cannot use this function to create UTF-8 format files.
At this time, we can use the adodb.stream object.
Set objstream = Server.createObject (Adodb.Stream)
With objstream
.Opeen
.Charset = UTF-8
.Position = objstream.size
.Writetext = STR
.Savetofile server.mappath (/sitemap.xml), 2
.Close
End with
Set objstream = Nothing
Attached::
ASCII, Unicode, UTF-8 Introduction:
ASCII is a character set, including the English letters, numbers, control characters, etc. of the case. It is represented by a byte, and the range is 0-127.
Because ASCII represents very limited characters, various countries or regions have proposed their own character sets, such as GB2312, which is widely used in China, which provides codes for Chinese characters and is represented by two bytes.
These characters are not compatible with each other. The same number may represent different characters, which brings trouble for information exchange.
Unicode is a character set that maps all characters in the world into a unique number (Code Point), such as the number 0x0041 corresponding to the letter A. At present, Unicode is still under development, and it is more and more tolerant.
When storing the characters represented by Unicode, a certain encoding method is required, such as UCS-2, which uses two bytes to represent the character encoded by Unicode. And UTF-8 is another encoding method of the Unicode character set. It is variable, up to 6 bytes, and less than 127 characters are represented by a byte. Like the result of ASCII characters, it has very good good ones Compatibility, the English text encoded by ASCII can be treated as UTF-8 coding without modification, and the application is very wide.