Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by mike hills on Jan 29, 2009 12:22
open dhtmlx forum
UTF-8 Characters in Grid Cells

We have been using the grid component for awhile with much success. However we have recently started to use it with international characters. For example we would embed a value in row as shown below.

<row id="QuotaGroup.103_QuotaGroupDetail.371" >
<cell><![CDATA[4145 - Hushàåäéöpparater - HVAC]]></cell>

This generates a "bad xml" error when loading the grid. The presence of these characters seems to cause a problem.

The javascript below is used to load the grid

mygrid.imgURL = "@CONTEXT@/_inc/dhtmlx_1.6/dhtmlxGrid/codebase/imgs/";
mygrid.loadXML(document.forms['form0'].elements['quoteDataResource'].value, disableQuoteProgressBar);

The XML returned is specified as being utf-8 encoded - is there anything else that might cause this? We are using 1.6
Answer posted by Support on Jan 30, 2009 00:46
>> The presence of these characters seems to cause a problem.
>> The XML returned is specified as being utf-8 encoded
By default XML uses UTF-8 encoding, in your case the data most probably written in some specific encoding ( most probably iso-8859-1 )
In such case you need change header of XML to the
<?xml version="1.0" encoding="iso-8859-1" ?>

The grid itself will work in same encoding as encoding of HTML page, so it can work with any encoding supported by browser. 

If problem still occurs - please provide a sample of problematic XML ( as attachment , to prevent modifications ) 
Answer posted by mike.hills@sematree.com on Jan 30, 2009 05:09
All of our HTML pages are encoded as UTF-8. The reason for this is that data is displayed from all parts of the globe - i.e. Asia, Europe, US. Shouldn't UTF-8 also handle iso-8859-1 characters as well?
Answer posted by Support on Jan 30, 2009 05:35
>>Shouldn't UTF-8 also handle iso-8859-1 characters as well?
UTF-8 may show the same glyphs as iso-8859-1 ( umlauts , accents, etc. ) , but if you will put data with umlauts in iso-8859-1 encoding inside UTF based XML - it will cause error. 
( while it may seems correct , the umlauts and other similar chars encoded as one byte value in iso-8859-1 and as multi-byte value in UTF)

If problem still occurs - please provide a sample of problematic XML ( as attachment , to prevent modifications )