The specific characteristics are as follows:
1, through the template to achieve normal Russian.
2. Static Russian information generated by the backstage database, the backstage display is normal, the foreground is garbled.
3, English is normal.
Similar or different expressions related to the subject
FSO Write UTF-8 encoding file
FSO how to generate a utf-8 encoded file
What is the default encoding format for the files generated by the FSO
How to convert into UTF-8 encoding
FSO to generate static web page problems
ASP in the use of FSO generated file code as follows
Copy Code code 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 argument-1 is to specify the encoding format for Unicode, and 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 that can be used to read or write the created file.
Object. OpenTextFile (filename[, iomode[, create[, format]])
Parameter object, required. Should be the name of the Filesystemobjec or Folder object. Here is the FSO.
FileName, required option. A string expression that indicates the file to create. This is sfilename.
IOMode, optional parameter that indicates whether the file is read, written, or appended, defaults to 1 for read, 2 for write, and 8 for append.
Create, optional parameter, set to True if the file does not exist, is false by default, and if you want to create it.
Format, the parameter can be one of the following settings, the default is ASCII format, and there is no utf-8 we want:
TristateUseDefault-2 opens the file in the system default format.
TristateTrue-1 opens the file in Unicode format.
Tristatefalse 0 Opens the file in ASCII format.
FSO has only three encoding properties, system defaults, UNICODE,ASCII, and there is no utf-8 we want, so the general Chinese system on the use of FSO components generated files are gb2312 encoding format.
Solution One
GB2312 encoding contains Russian letters, if the page is set to the Simplified Chinese GB2312, then the Russian can be displayed normally, but because the Chinese default "XXFarEastFont-Arial" display, in the "XXFarEastFont-Arial" Russian will be displayed as full-width characters, it is difficult to see, so to use foreign fonts, such as "New Rome" or "Arial". Chinese customers can do it, but when the real Russians browse the page, they need to download and install Chinese, which is not ideal, and is likely to lead to a waiver of browsing.
Workaround Two
ASP because it is an ancient language, some of its functions for UTF-8 support is very poor. The FSO does not support directly generating UTF-8 format files because it cannot specify the desired file format, for example, if you want to generate a UTF-8 format file, use a commonly used Scripting.FileSystemObject object. Must change a way of thinking, with ADODB.stream, some of the current blog program is such a realization, such as Zblog.
The Scripting.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.
However, you cannot use this function to create a UTF-8 format file.
Using the ADODB.stream object, use the method below:
Copy Code code 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 With
Set objstream = Nothing
Appendix: Introduction to ASCII, Unicode, UTF-8
ASCII is a character set, including uppercase and lowercase letters, numbers, control characters, and so on, which are expressed in one byte, and the range is 0-127.
Since ASCII represents a very limited number of characters, each country or region proposes its own character set on this basis, such as GB2312, which is widely used in China, which provides the 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.
When storing Unicode-represented characters, you also need some encoding, such as UCS-2, which represents Unicode-encoded characters in two bytes. The UTF-8 is another encoding of the Unicode character set, which is variable length, up to 6 bytes, and less than 127 characters in a byte, and, like the result of the ASCII character set, has very good compatibility. The English text under ASCII code can be treated as UTF-8 code without modification, and its application is very extensive.