Copy link to clipboard
Copied
Hello,
I generated a xml file in UTF-8 format which is right readeable using IE9.
This file contains some accented character and in IE9 these characters are all readeable.
After parsing this file using xmlParse and obtaining the resulting array, i try to show the content of one memo field present in an array element but the accented characters are substituted by a wrong rappresentation (like a wrong encoding).
I check (by the browser) that the page is rightly UTF-8 encoded like the xml file.
Why the accented characters are not shown in the right way despite the xml file and the page are UTF-8 encoded ?
Thanks,
Davide
Ah, right. Gotcha.
There's a bug in xmlParse() in that when reading from the file system, it doesn't understand that files can have different encoding schemes. Sad but true.
See the ticket I've raised with Adobe here:
https://bugbase.adobe.com/index.cfm?event=bug&id=3183072
Short version: use fileRead() to read the file, then xmlParse() the result.
NB, according to CF, you have a bug in your XML:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
The standalone attribute value must be one of ye
...Copy link to clipboard
Copied
When you say, "i try to show the content of one memo field present in an array element", what should we understand by show? Do you mean using cfoutput?
Copy link to clipboard
Copied
Similar to BKBK's reaction... instead of describing your code, show us your code. Or at least a code snippet that demonstrates/replicates your problem. It's unlikely we can guess what your problem is, which is what you're relying on us doing without letting us see some code that demonstrates what you're talking about.
--
Adam
Copy link to clipboard
Copied
Here's the code...
Following the .cfc which return me the array of xml struct:
var xmlObject = xmlParse(expandPath("Data/Pratiche.xml"));
var xPathString = "";
var result = "";
if (CustomerID > "")
{
xPathString = "/DATAPACKET/ROWDATA/ROW[@CustomerID =" & CustomerID & "]";
result = xmlSearch(xmlObject, xPathString);
}
return result;
And here there's the code which output the result :
<cfcontent type="text/xml; charset=UTF-8">
<cfinvoke component="cfcs.praticheDAO"
method="readByParams"
idcliente="3"
returnvariable="pratiche">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8"/>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<cfoutput>
<cfloop array="#pratiche#" index="p">
<div style="width:720px; font-family:Arial, Helvetica, sans-serif; font-size:11px; border:0;">
<div style="width:720px; margin:5px 0;">
<div style="position:relative;width:30px; border:1px solid ##333333; background-color:##ffffff; margin-left:10px; text-align:center; z-index:2">Note</div>
<div style="position:relative;width:710px; border:1px solid ##333333; border-radius:5px; padding:8px 5px 5px 5px; margin:-6px 0 5px 0; z-index:1;">
#p.xmlAttributes.NotePub# <- this is the xml value I'm trying to output
</div>
</div>
</div>
</cfloop>
</cfoutput>
</body>
</html>
The results is :
La società debitrice è in liquidazione coatta amministrativa. <- here's the wrongs charcters they should be à and è
Abbiamo provveduto a comunicare al Commissario liquidatore l'importo complessivo del credito.
Ammessi al chirografo per L.2.473.460.
DIFFIDA INVIATA E NON RICEVUTA. 1 RICEVUTA
Si è depositata la domanda di ammissione al passivo <- here's the wrong char it should be è
AMMESSO TUTTO AL CHIROGRAFO
Here an extract from the xml file like I view it in IE9:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<DATAPACKET Version="2.0">
<ROWDATA>
<ROW Data="20000717" NotePub="La società debitrice è in liquidazione coatta amministrativa. Abbiamo provveduto a comunicare al Commissario liquidatore l'importo complessivo del credito. Ammessi al chirografo per L.2.473.460." AttIst="FALSE" Concordato="TRUE" Fallimento="FALSE" RagSocDeb="ORTO PIU' SOC. COOP. A R.L." CodDeb="RP49" NumDec="" Acconti="0.0000" Emissione="20001230" ValMat="0.0000" Notifica="20010103" Deposito="20001115" ValCap="1001.1899" IDCliente="3" IDPratica="196"/>
<ROW Data="20030120" NotePub="DIFFIDA INVIATA E NON RICEVUTA. 1 RICEVUTA Si è depositata la domanda di ammissione al passivo AMMESSO TUTTO AL CHIROGRAFO" AttIst="FALSE" Concordato="FALSE" Fallimento="TRUE" RagSocDeb="NIKO MARKET S.R.L." CodDeb="VQ23" Acconti="0.0000" ValMat="0.0000" ValCap="430.4600" IDCliente="3" IDPratica="1375" UdiVer="20030922"/>
</ROWDATA>
</DATAPACKET>
Finally i notify you the the application run on a ColdFusion server with an english SO and I'm viewing the page with an Italian IE9.
I hope I give you the needed information.
Thanks for your support,
Davide
Copy link to clipboard
Copied
Ah, right. Gotcha.
There's a bug in xmlParse() in that when reading from the file system, it doesn't understand that files can have different encoding schemes. Sad but true.
See the ticket I've raised with Adobe here:
https://bugbase.adobe.com/index.cfm?event=bug&id=3183072
Short version: use fileRead() to read the file, then xmlParse() the result.
NB, according to CF, you have a bug in your XML:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
The standalone attribute value must be one of yes or no, not true or false (this was on CF 9.0.1).
This is borne out by the guidance by the W3C: http://www.w3.org/TR/REC-xml/#sec-rmd
--
Adam
Copy link to clipboard
Copied
Splendid job, Adam. I have voted to have the bug fixed.
Copy link to clipboard
Copied
Adam Cameron. wrote:
use fileRead() to read the file, then xmlParse() the result.
Meaning, of course, fileRead() with an encoding attribute of "UTF-8" (as you yourself point out in the bug report). Without the encoding attribute, fileRead misbehaves just like xmlParse.
Copy link to clipboard
Copied
use fileRead() to read the file, then xmlParse() the result.
Meaning, of course, fileRead() with an encoding attribute of "UTF-8" (as you yourself point out in the bug report). Without the encoding attribute, fileRead misbehaves just like xmlParse.
Yeah, sorry, I thought that was obvious from what I was saying, but it's perhaps a good idea to make it crystal clear.
--
Adam
Copy link to clipboard
Copied
Hello Adam,
of course many thanks by me.
Your response arrives quickly and solve the problem.
Davide