Christoph
Wed Sep 08 18:45:06 CDT 2004
08.09.2004 23:04, Dan Tan schrieb:
> I'm creating files on an IIS 5.0 web server, and when I create files with
> the FileSystemObject, it creates files that have ASCII 0's as every other
> character.
> For example, if I TextStream.Write("Hello"), the resulting file has:
>
> (gibberish) H (null) e (null) l (null) l (null) o (null)
>
> In a text editor, the output looks fine, like "Hello".
> In a hex editor, the file looks like this:
>
> FF FE 48 00 65 00 6C 00 6C 00 6F 00
>
> Anyone have an idea what's going on? It's driving me nuts...
The TextStream is opened as Unicode.
Some people mix up CreateTextFile and OpenTextFile params.
As for CreateTextFile, the third-Param (Tristate) stands for Unicode
vs Ascii, while for the OpenTextFile-Method the third param is
boolean and flags OverwriteExisting.
So:
Set stream = fs.CreateTextFile("C:\my.txt", true, true)
will open the file as Unicode, while
Set stream = fs.CreateTextFile("C:\my.txt", true, false) 'OR:
Set stream = fs.CreateTextFile("C:\my.txt", true) 'OR:
Set stream = fs.OpenTextFile("C:\my.txt", 2, true)
will open it as ASCII. ASCII is default.
> I'm not sure where the "FF FE" comes from either.
So called "Byte-Order-Mark" (->BOM) for Unicode-Files. It declares
the ByteOrder. FF EE is Little Endian for UTF-16.
http://www.opentag.com/xmli18nfaq.htm#enc_bom
--
Gruesse, Christoph
Rio Riay Riayo - Gordon Sumner, 1979