1 Reply Latest reply on Jan 21, 2009 11:02 AM by flexstone

    FileStream: writeMultiByte:  Problem writing special characters


      I'm having a problem with FileStream. I have an XML that I have
      loaded from the hard drive, edited in my AIR app and I want to write it
      back to the hard drive. It includes special characters such as the TM
      symbol, which I've been unable to find a way to write to the drive.

      If I use:

      the_filestream.writeMultiByte(the_xml.toString(), "iso-8859-1");

      ...it writes "â„¢" instead of the TM symbol. And if I use UTF-8 it just writes the
      letter "T".

      Something else that's a bit odd, and perhaps related: If I save any .xml file, created in a text editor, as UTF-8 encoding it breaks when I try to load it into AIR using FileStream. But if I save it as ANSI it works.. even when I use "UTF-8" in the readMultiByte function. Which I have to do or it loses the special characters like the TM symbol, which it turns into "â?¢" when I use "iso-8859-1".

      Thank you.
        • 1. Re: FileStream: writeMultiByte:  Problem writing special characters
          flexstone Level 1
          This is the way that works for me. You need to use UTF-8 encoding.....

          var fileName = "myXMLFile.xml"
          var fileRef:FileReference = new FileReference()

          var fl:File = File.applicationStorageDirectory.resolvePath(fileName);
          var fs:FileStream = new FileStream();

          //create XMLDocument

          var xDoc:XMLDocument = new XMLDocument(myXML)
          var xStr = xDoc.toString()
          //open file in write mode
          //write bytes from the byte array