XML, UTF-8 and accented chars
Posted: 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:
I have another button to read the flds and write to a USB device:
I can read the XML file retrieve data and put it into specific flds:
The problem is the file You can’t post image, email or url links that are external to this domain.
instead of what I expect for further use outside LiveCode:
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
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
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
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é</name><surname>Malraux</surname></identity>
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'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