ASP generates HTML files with static file encoding for UTF-8 format _ Application Tips

Source: Internet
Author: User
In general, we are in the ASP environment, the operation of static operations are used in the FSO, he is specialized in the operation of a file component, he FSO's code attributes only three kinds, the system defaults, UNICODE,ASCII, and no we want the utf-8, So the general Chinese system on the use of FSO components generated files are gb2312 format, even if you write in the Web page charset= "Utf-8" is useless

To generate files in utf-8 format, we use ADODB in the ASP environment. Stream instead of FSO read and write Utf-8 file, because, ADODB. Stream, there is a CharSet property that lets you define the encoding type of the file you want to open or write to, so ADODB. Stream is not only read or write utf-8 files, basically what format files can be manipulated, of course, the current more useful for us is written as utf-8 format files,

The following function can implement these functions:

Function WriteToFile (FILEURL, STR, CharSet)
Set stm = CreateObject ("ADODB.stream")
Stm. Type = 2
Stm.mode = 3
Stm.charset = CharSet
Stm. Open
Stm. WRITETEXT STR
Stm. SaveToFile FILEURL, 2
Stm.flush
Stm. Close
Set stm = Nothing
End Function

Where CharSet can choose a lot of items, you can find what you want: Web page code Daquan CodePage CharSet in English display name, this function is basically the function of your dynamic static use of the FSO function, just a choice of character encoding attributes, Of course, you can also write this attribute directly into the function, but this is better to write, later if you want to use another format, this function can also be used, do not have to modify.

If you just want to implement the existing file batch conversion to UTF-8 format, you can try:
Batch gb2312 turn utf-8, support drag, VBS implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.