The specific features are as follows:
1. Use a template to perform normal operations in Russian.
2. The static Russian information generated by the background database is displayed normally in the background and garbled on the foreground.
3. English is normal.
Similar or different expressions related to the topic
FSO write UTF-8 encoding File
How can FSO generate UTF-8 encoded files?
What encoding format is the default file generated by FSO?
How to convert to UTF-8 Encoding
FSO static webpage generation
Generate a file using FSO in ASP
Code As follows:
Copy code The Code is as follows: function createfile (sfilename, scontent)
Set FSO = server. Createobject ("scripting. FileSystemObject ")
Set F1 = FSO. opentextfile (sfilename, 2, true,-1)
F1.write (scontent)
F1.close
Set FSO = nothing
End Function
FSO. opentextfile (sfilename, 2, true,-1) The last parameter-1 is to specify the encoding format for Unicode, the encoding format for Unicode is displayed on the web page as UTF-16 little-Endian.
Opentextfile Method
Creates a specified file and returns a textstream object. This object can be used to read or write the created file.
Object. opentextfile (filename [, iomode [, create [, format])
Parameter object, required. The name of the filesystemobjec or folder object. Here is FSO.
Filename, required. String expression, indicating the file to be created. Here is sfilename.
Iomode, an optional parameter, indicating whether the file is used for reading, writing, or appending. The default value is 1, indicating reading, 2 indicating writing, and 8 indicating appending.
Create, an optional parameter. If the file does not exist, the default value is false. If you want to create a file, set it to true.
The format parameter can be one of the following settings. The default format is ASCII, And the UTF-8 format is not required:
Tristateusedefault-2 open a file in the default format.
Tristatetrue-1 open a file in unicode format.
Tristatefalse 0 open the file in ASCII format.
FSO has only three encoding attributes. The system defaults to Unicode and ASCII, and does not use UTF-8. Therefore, files generated by the FSO component on Chinese systems are generally in gb2312 encoding format.
Solution 1
Gb2312 encoding contains Russian letters. If the page is set to simplified Chinese gb2312, the Russian language can be displayed normally, but the Chinese default is ", in "", Russian is displayed as full-angle characters, which is ugly. Therefore, foreign fonts, such as "New Rome" or "Arial", are used. Chinese customers can communicate with each other, but when the real Russians browse the page, they need to download and install Chinese characters. This is not ideal and may lead to the abandonment of web pages.
Solution 2
Since ASP is an old language, some of its functions have very poor support for UTF-8. FSO does not support directly generating files in UTF-8 format because it cannot specify the desired file format, for example, to generate a file in UTF-8 format, using a commonly used scripting. FileSystemObject object won't work. You must use ADODB. Stream to change the existing blog Program This is the implementation, such as zblog.
Scripting. FileSystemObject:
FileSystemObject. createtextfile (filename [, overwrite [, Unicode])
The Unicode attribute is described as follows:
Optional. Boolean indicates whether to create a file in Unicode or ASCII format. If a file is created in unicode format, the value is true. If a file is created in ASCII format, the value is false. If this part is omitted, an ASCII file is created.
Obviously, this function cannot be used to create a UTF-8 format file.
You can use the ADODB. Stream object as follows: Copy code The Code is as follows: 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
Set objstream = nothing
Appendix: ASCII, Unicode, UTF-8 introduction
ASCII is a character set, including uppercase and lowercase English letters, numbers, control characters, etc., it is represented in a byte, the value range is 0-127.
because ASCII characters are very limited, each country or region has its own character set. For example, gb2312, which is widely used in China, provides encoding for Chinese characters, it is expressed in two bytes.
these character sets are incompatible with each other. The same numbers may indicate different characters, which makes information exchange troublesome.
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. Unicode is still in development, and more characters are supported.
when storing Unicode characters, some encoding methods are required, such as UCS-2, which uses two bytes to represent Unicode characters. While UTF-8 is another encoding method of the Unicode character set, it is a variable length, up to 6 bytes, less than 127 characters are represented in one byte, the same as the results of the ASCII character set, therefore, it has a very good compatibility. The English text in ASCII encoding can be processed as a UTF-8 without modification. It is widely used.