Page 1 of 1

problem in revxml and unicode

Posted: Sat Nov 02, 2013 5:23 am
by terryho
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

Re: problem in revxml and unicode

Posted: Mon Nov 11, 2013 4:46 pm
by Mark
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

Re: problem in revxml and unicode

Posted: Sat Nov 16, 2013 8:21 am
by terryho
Hi

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

Regards

terry Ho