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