1 Reply Latest reply on Apr 2, 2008 4:51 AM by Kasyan Servetsky

    read and write UTF-16

      Hi

      I need to read and write a file using UTF-16 encoding to preserve chars like "ë". The file actually is an xml file, but the header (which of course could contain the encoding as an attribute) gets stripped when i write back the XML

      this.xmlFile.open("r");
      var contents = this.xmlFile.read();
      this.xmlFile.close();

      How can I preserve my accented characters?

      thnkz
        • 1. Re: read and write UTF-16
          Kasyan Servetsky Level 5
          Hi james,

          Why don't you use import/export XML methods?

          myDocument.xmlElements.item(0).importXML(File("/c/MyXML_file.xml"));
          myDocument.exportFile(ExportFormat.xml, File("/c/MyXML_file.xml"));

          You can set encoding of a text file in the property of the same name:

          var myText = "some text";
          myFile = new File("~/Desktop/test.txt");
          myFile.encoding = "UTF16"
          myFile.open("w");
          myFile.write(myText);
          myFile.close();

          Kasyan