XML, UTF-8 and accented chars

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
charles_l
Posts: 4
Joined: Thu Jan 22, 2015 11:43 pm

XML, UTF-8 and accented chars

Post by charles_l » Sat Mar 07, 2020 10:33 pm

I'm trying to build an XML file from fields in LiveCode. The text in the fields contains accented chars.

I have a button to initialize the XML tree:

Code: Select all

--button init tree
global idID

on mouseUp pMouseButton
   if revXMLTrees() is not empty then revXMLDeleteAllTrees
   put "<identity></identity>" into tData
   put revCreateXMLTree (tData, true, true, false) into idID
   revXMLAddNode idID, "/", "name", ""
   revXMLAddNode idID, "/", "surname", ""
end mouseUp
I have another button to read the flds and write to a USB device:

Code: Select all

--button add&write
global idID

on mouseUp pMouseButton
   revXMLPutIntoNode idID, "/identity/name",  textEncode (field  "name_source" ,"UTF8") -- fld contains "André"
   revXMLPutIntoNode idID, "/identity/surname",  textEncode (field  "surname_source" ,"UTF8") -- fld contains "Malraux"
   answer revXMLText (idID) -- the accented char is there
   put revXMLText (idID) into URL You can’t post image, email or url links that are external to this domain. -- no readable accented char in there
   -- same result with binfile: OR file:
end mouseUp
I can read the XML file retrieve data and put it into specific flds:

Code: Select all

--button read
on mouseUp pMouseButton
   put url (You can’t post image, email or url links that are external to this domain.) into tMyXML
   put revXMLCreateTree(tMyXML, false, true, false) into tTree
   put revXMLNodeContents(tTree, "identity/surname") into tSurname
   put revXMLNodeContents(tTree, "identity/name") into tName
   put textDecode (tSurname, "UTF-8") into fld "surname_target" -- fld reads "Malraux"
   put textDecode (tName, "UTF-8") into fld "name_target" -- fld reads "André"
end mouseUp

The problem is the file You can’t post image, email or url links that are external to this domain.

Code: Select all

<?xml version="You can’t post image, email or url links that are external to this domain."?>
<identity><name>Andr&#xE9;</name><surname>Malraux</surname></identity>
instead of what I expect for further use outside LiveCode:

Code: Select all

<?xml version="You can’t post image, email or url links that are external to this domain."?>
<identity><name>André</name><surname>Malraux</surname></identity>
I'd like to avoid deprecated properties or functions such as uniCodeText, uniEncode, uniDecode.

I'm certainly missing something obvious.

Any hint ?

CL


Sorrry for
You can’t post image, email or url links that are external to this domain.
that replaces snippets not allowed in this forum

It's not my point today, but help would be appreciated

bogs
Posts: 5434
Joined: Sat Feb 25, 2017 10:45 pm

Re: XML, UTF-8 and accented chars

Post by bogs » Sat Mar 07, 2020 10:46 pm

charles_l wrote:
Sat Mar 07, 2020 10:33 pm
Sorrry for
You can’t post image, email or url links that are external to this domain.
that replaces snippets not allowed in this forum

It's not my point today, but help would be appreciated
While I can't answer your actual question, the above at least will go away when you hit ten posts :D
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”