Page 1 of 1

XML, UTF-8 and accented chars

Posted: Sat Mar 07, 2020 10:33 pm
by charles_l
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

Re: XML, UTF-8 and accented chars

Posted: Sat Mar 07, 2020 10:46 pm
by bogs
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