PHP : How to handle UTF8 XML File

100 views
Skip to first unread message

Andre Lacasse

unread,
May 2, 2013, 11:15:26 AM5/2/13
to haxe...@googlegroups.com
Hi everyone,

I try to read a UTF8 XML file and parse on PHP target. The file encoding is UTF8 without BOM and the file start with <?xml version="1.0" encoding="UTF-8"?>.

var content:String = File.getContent( "texts_fr.xml" );
var doc:Xml = Xml.parse(content);

The parse method stop to the first accentued character.

var content:String = Utf8.decode( File.getContent( "texts_fr.xml" ) );
var doc:Xml = Xml.parse(content);

The Xml.parse return exception for invalid character.

How to handle UTF8 file with French character on the PHP target?

Thank for answer.

Victor / tokiop

unread,
May 2, 2013, 3:36:23 PM5/2/13
to haxe...@googlegroups.com
Hi Andre,

didn't test it for xml, and there may be better way (haxe utf8
strings?), but this helped regarding uf8 strings in php :

#if php
content = untyped __call__("utf8_decode", content);
#end

Victor


Le 02/05/13 17:15, Andre Lacasse a �crit :

Andre Lacasse

unread,
May 3, 2013, 9:52:09 AM5/3/13
to haxe...@googlegroups.com
Doesn't work because the Utf8.decode(String ) is equivalent to write the untyped__call.


Le jeudi 2 mai 2013 15:36:23 UTC-4, tokiop a écrit :
Hi Andre,

didn't test it for xml, and there may be better way (haxe utf8
strings?), but this helped regarding uf8 strings in php :

#if php
   content = untyped __call__("utf8_decode", content);
#end

Victor


Le 02/05/13 17:15, Andre Lacasse a �crit :
Reply all
Reply to author
Forward
0 new messages