Menu

character encoding

Help
2016-05-30
2016-05-30
  • Chaubert Jérôme

    Hi,

    How does function (open file writeFile "w") determine the character encoding of the created file ?

    I work on windows and I get sometimes "cp1252" and sometimes "UTF-8"

     
  • Gary Riley

    Gary Riley - 2016-05-30

    It's not explicitly set—it's determined by the underlying implementation of the C libraries. On Windows, it's the fopen_s function (which is a more secure implementation of fopen). I did a simple test and it appears that if you write plain ASCII to the file, it's saved as plain ASCII. If you write any characters requiring a unicode representation, it's saved as UTF-8 without a BOM (Byte Order Mark). On Linux and Mac OS, fopen is used and the encoding is set to UTF-8 without a BOM whether you write plain text or unicode text.

     

Log in to post a comment.