problem in revxml and unicode

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

problem in revxml and unicode

Post by terryho » Sat Nov 02, 2013 5:23 am

Hi,

I have problem in RevXMl. I cannot convert the unicode from the xml text.

Please test the attach livecode file.

I put the xml text in the field "Result"

I can use this scrip to get the unicode text
"set unicodetext of field "Test" to unicodetext of char 27 to 30 of line 9 of field "Result"

But if I use the revxml method I can not get the unicode text and only get unreadable character

Does I make something wrong, Please advise

Regards

Terry Ho
Attachments
XmlUnicode.livecode.zip
(2 KiB) Downloaded 250 times

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: problem in revxml and unicode

Post by Mark » Mon Nov 11, 2013 4:46 pm

Hi Terry Ho,

The first line of your XML data must be

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
I wrote about this in my book ;-)

The mouseUp handler in your XML button should be

Code: Select all

on mouseUp
   put "" into field "test"
   // Create UTF8 formatted XML tree
   put revCreateXmlTree(unidecode(the unicodeText of \
         Field "Result","UTF8"), false, true, false) into tiD
   put revXMLNumberofChildren(tID,"/Envelope/body/data","group", 0) into tNOC
   put "" into tbuffer
   repeat with tcount = 1 to tNOC
      // retrieve UTF8 formatted data from XML tree
      put revXMLNodeContents(tID, "/Envelope/body/data/group[" & \
            tcount & "]/CHINESENAME") into adate
      // tab and cr are the same in ASCII and UTF8
      put aDate & tab & cr into bbuffer
      put bbuffer after tbuffer
   end repeat
   // convert UTF8 to UTF16
   set the unicodeText of fld "test" to uniEncode(tbuffer,"UTF8")
end mouseUp
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

Re: problem in revxml and unicode

Post by terryho » Sat Nov 16, 2013 8:21 am

Hi

Thanks you help. I found the problem. Just as you said the Unicode problem

Regards

terry Ho

Post Reply