My Books

  • Follow me on Twitter

Comtaste's Projects

  • Flex Solutions: Essential Tecniques for Flex 3 Developers - The Site
  • Comtaste, Flex 3, AIR and Java consulting
  • YouThru Multimedia Web Messaging
  • MobyMobile
  • UserMatter(s) Magazine
My Photo

Subscribe my blog

  • Get this widget from Widgetbox
  • Add to Google
  • RSS FEEDS
  • Enter your Email here to subscribe :



    Powered by FeedBlitz

« AJAX (Adobe Spry) and AIR development using Aptana IDE | Main | Garbage Collector in ActionScript 3 »

Considering the byte order mark (UTF-BOM) when reading a text file using the readUTF() method in AIR

Working with Adobe AIR's d ead and write methods, we encountered  some strange behaviors when using the readUTF() method to read text files (TXT or RTF).
In fact if the text file we're opening has not been created by Adobe AIR,  we got a runtime error (number #2030 line ending ....) from the Flash Player. Investigating we discovered that the readUTF() method won't find a couple of bytes embedded into the file that it needs.

From the Adobe AIR  documentation :

The readUTF() and the writeUTF() methods (not to be confused with readUTFBytes() and writeUTFBytes()) also read and write the text data to a file, but they assume that the text data is preceded by data specifying the length of the text data, which is not a common practice in standard text files.

Some UTF-encoded text files begin with a "UTF-BOM" (byte order mark) character that defines the endianness as well as the encoding format (such as UTF-16 or UTF-32).

Instead, reading the file using the writeUTFBytes() everything works well.
I'm trying to understand if the IDataInput and IDataOutput objects are responsible for the serialization/deserialization.

Anyone had the same problem ?

when 

Comments

Post a comment

If you have a TypeKey or TypePad account, please Sign In

Pistach.io

Speaker at

Upcoming Conferences

  • FITC200x200.jpg
  • AJAXWorld
  • CFUnited
  • SOA World Conference
  • iPhone Summit
  • 360Flex Europe

WebDeveloper's Journal Author

  • My favourite Flash Lite 3 mobile phone
  • Web Developer's & Designer's Journal by Sys Con Media
  • Web Developer's & Designer's Journal Blogger
    Web Developer's & Designer's Journal by Sys Con Media
  • FullAsGoog Aggregator
  • Macromedia WebLogs Aggregator

May 2008

Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31