Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: [1]
1  PureMVC Manifold / Demos and Utils / Re: XMLDatabase - A PureMVC AS3 / AIR Utility on: January 11, 2009, 07:56:35
Here you go Cliff. Just a basic xml file which includes the BOM.

Cheers,
Brendan
2  PureMVC Manifold / Demos and Utils / Re: XMLDatabase - A PureMVC AS3 / AIR Utility on: January 08, 2009, 09:47:08
Great utility Cliff, thanks! One problem I've come across is when attempting to load xml from a utf-8 encoded file which includes the 3-byte BOM up front. The xml constructor baulks at trying to parse the string read from the file stream as it ignores the BOM. I got around this by overriding the XMLDataProxy.read() method as follows:
:
override protected function read():XML
{
// Read the database file into an XML object and return it
var dbStream:FileStream;
dbStream = new FileStream();
dbStream.open(dbFile, FileMode.READ);

// Accomodate byte order marker
if (((dbStream.readUnsignedByte() << 16) | (dbStream.readUnsignedByte() << 8) | dbStream.readUnsignedByte()) ^ 0xEFBBBF) {
dbStream.position = 0;
}

var dbXML:XML = XML(dbStream.readUTFBytes(dbStream.bytesAvailable));
dbStream.close();
return dbXML;
}

Cheers!
Pages: [1]