Where is Andr? ? Andr? says "goodbye"

Mark Waddingham mark at livecode.com
Sun Mar 15 07:25:47 EDT 2020


On 2020-03-15 10:29, OLIVER GMAIL via use-livecode wrote:
>> It s revXMLText (idID) that converts high ASCII characters to HTML
>> entities, so I don't think file vs binfile will make much difference.
> 
> I noticed a similar issue with revXMLPutIntoNode. The forum post is
> here: https://forums.livecode.com/viewtopic.php?f=9&t=33726
> 
> Not many answers since February 4 unfortunately...  perhaps the list 
> can help?

Something like this should solve the issue (beware of wrapped lines!):

on mouseUp
    local tInitialXML, tXmlId
    put "<?xml version='1.0' 
encoding='UTF-8'?><identity><name></name></identity>" into tInitialXML
    put revXMLCreateTree(tInitialXML,false,true,false) into tXmlId
    revXMLPutIntoNode tXmlId, "/identity/name",  textEncode("André", 
"utf-8")
    put revXMLText(tXmlId) into URL 
("binfile:"&specialFolderPath("desktop")&slash&"myFile.xml")
end mouseUp

You have to create the XML tree with an initial `<?xml` line so that 
libxml2 knows what encoding you want - utf-8 will give what the 
use-cases here have requested.

Then, you have to textEncode any text you use as utf-8 before passing it 
to the command/function (usually just content, but also attributes, 
element names or attribute values - if any may contain non-ascii text).

Finally, revXMLText will return an already encoded bit of binary data 
you can put into a file - hence binfile.

Hope this helps!

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps



More information about the use-livecode mailing list