XML Tree not returning cyrillic characters

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm

XML Tree not returning cyrillic characters

Post by raugert » Sun Dec 20, 2020 7:01 am

When I create a tree from an XML file (revXMLCreateTree) and parse the data to retrieve an attribute, it doesn't return the cyrillic characters. It does however return the french characters (é). I thought it might be a "textDecode" issue but the XMLData in the field is already UTF-8 textDecoded...

Here's the code in the button:

Code: Select all

on mouseUp pButtonNumber
   put empty into field "XMLDecoded"
   put revXMLCreateTree(field "XMLData", false,true,false) into tTree
   put revXMLAttributeValues(tTree,"xml/group/",person,"title",return,1) into field "XMLDecoded"
end mouseUp

thanks for any insight,
Richard
(using Livecode Indy 9.6.1 on Mac)

Here's a simple stack to illustrate.
Attachments
Parsing XML with Cyrillic characters.livecode.zip
(1.41 KiB) Downloaded 166 times
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0

raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm

Re: XML Tree not returning cyrillic characters

Post by raugert » Sun Dec 20, 2020 7:36 pm

I discovered that in order to retain cyrillic characters, the XML text must be textEncoded before creating an XML Tree. Then each attribute that may contain these cyrillic characters needs to be textDecoded.

--- This works ---

Code: Select all

on mouseUp pButtonNumber
   put empty into field "XMLDecoded"
   put textEncode (field "XMLData" , "UTF-8") into tXMLData  -- need to encode before creating tTree
   put revXMLCreateTree(tXMLData, false,true,false) into tTree
   put textDecode (revXMLAttributeValues(tTree,"xml/group/","person","title",return,1), "UTF-8") into field "XMLDecoded"  --need to decode each attribute that may contain a cyrillic character
end mouseUp
I'm not sure why I would have to encode text for an XML Tree, but in any case, it seems to work. :)

cheers,
Richard
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0

Post Reply