Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Christian on Aug 04, 2009 10:06
open dhtmlx forum
dhtmlxconnector and special characters

When I try to load on the dhtmlxgrid data with accents or special characters like & get an error "Incorrect XML"

To load the data I'm using dhtmlxconnector
         
Is there a way to solve this

Answer posted by Support on Aug 05, 2009 01:27
Which component is used in problematic case?
Normally , connectors wraps all data in CDATA sections, so special chars can be processed without extra handling. 


You can try to use beforeRender event to workaround the issue.
function my_escape($data){
           $value = $data->get_value("field_name");
           $value = str_replace("&","&",$value);
           $data->set_value("field_name",$value);
}
$comp->event->attach("beforeRender","my_escape");

Answer posted by Chris on Aug 05, 2009 09:38
Sorry for the confusion & works well
The problem happens with the Spanish accent (á, é, í, ó, ú)

The components used are dhtmlxgrid v.2.1 build 90226 and dhtmlxConnector for PHP v.0.9 build 90226
Answer posted by Support on Aug 06, 2009 02:49
>>with the Spanish accent (á, é, í, ó, ú)
Which encoding you are using for data storage?
By default connector expect urf-8 usage, if you are using different encoding ( iso-8859-1 most probably ) you need to add the next line to the connector initialization code


$grid->set_encoding("iso-8859-1"); //sets xml encoding
$grid->render_ ...