creating a Unicode (UTF-8) file using open/write/close file

Dar Scott dsc at swcp.com
Wed Sep 24 17:43:00 EDT 2003


On Wednesday, September 24, 2003, at 01:15 PM, Trevor DeVore wrote:

> I tried to create a file from Rev by pasting the contents of the XML 
> file I made in BBEdit into a field and using the following code:
>
> open file tPath for write (also tried open file tPath for binary write)
> write unicodeText of field 1 to file tPath
> close file tPath
>
> The Japanese characters were turned into garbage characters when I 
> opened the file in BBEdit.  Is it possible to write a UTF encoded text 
> file with Rev?  If so, how?

The unicodeText property does not include a BOM (byte order marker).  
Does BBEdit need one?  Flash files probably do.

The unicodeText property returns a form of UTF-16.  Is that what BBEdit 
is expecting?

You might want to look at the hex of the original file and the hex of 
the created file.  Or, better yet, the hex of a much smaller test file.

Dar Scott




More information about the use-livecode mailing list