Use Vbscript to write scripts for merging text files

Source: Internet
Author: User

The script for merging text can be written as follows: CopyCode The Code is as follows: Sub appendtextfile (filename)
Set objtextfile = objfso. opentextfile (filename, forreading, true,-2)
Do until objtextfile. atendofstream
Objoutfile. writeline (objtextfile. Readline)
Loop
End sub

However, if the file to be read is in UTF-8 format, the three byte identifiers at the beginning of the file will be considered as data by the script, so that the identifiers become garbled characters in the merged file.
FSO provides parameters for opening Unicode files, but it does not take effect here.

Tristateusedefault

-2

Opens the file using the system default.

Tristatetrue

-1

Opens the file as Unicode.

Tristatefalse

0

Opens the file as ASCII.

I consulted the Google guru and found someone who said that using openastextstream is acceptable. Unfortunately, it is still unsuccessful in my environment.

Another idea is that when reading a file, you can determine whether the file starts with three byte identifiers. This is also determined as a non-feasible method, because the read provided by FSO is read by character, in this way, in a Chinese environment, we cannot just read these three bytes.

Similar problems are confirmed by Microsoft in IIS6, and there seems to be a corresponding patch, but it still does not seem to have been modified in the case of batch processing files.
Finally, msdn is very helpful, but its address is not easy to find. Record it:
Http://msdn.microsoft.com/en-us/library/ms950396.aspx

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.