cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
yossiz-algotec
Level 3

Bug: read/write a Unicode file

Hi,
I'm using InstallShield 2013 Premier with SP1.

I've prepared a little test - an InstallScript MSI project that executes the following code:

szFile = TempFolder ^ "web.config"; // A UTF-8 file
listID = ListCreate (STRINGLIST);
ListReadFromFile(listID,szFile);
ListWriteToFile(listID,szFile);
ListDestroy(listID);

Despite the claim that "if the file already exists and the pre-existing file is Unicode, it writes the file as Unicode", the resulting file is actually ANSI, with two strange characters at the beginning of the file (I assume this is due to the Unicode BOM).

Seems like a bug to me.

Any idea how to resolve, or at least workaround this issue?
Labels (1)
0 Kudos
(2) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

Unfortunately there's confusion to what the term "Unicode" means. In a Windows context it often means specifically UTF-16-LE, and in files typically requires the UTF-16 BOM be present on the file. This is the meaning of Unicode used in the description of the InstallScript functions. In this context, UTF-8 is not exactly considered Unicode, although sometimes a UTF-8 signature/BOM can elicit the behavior you need.
0 Kudos
yossiz-algotec
Level 3

Thanks Michael,

Indeed, if I convert the file to UCS-2 (UTF-16) LE, the code works fine.
I would appreciate if you could add it to the documentation.
0 Kudos