3 Replies Latest reply on Apr 8, 2011 12:20 PM by mrbahr

    Displaying UTF-8 Characters in Flex from XML

    mrbahr Level 1

      I am having a problem displaying UTF-8 encoded strings that are XML in flex components.  I have verified that the data is being stored correctly in MySQL and that the XML has the correct encoding.  I can display the XML in a browser and it displays correctly.

       

      I am using BlazeDS to transfer the string from the Java server to the Flex client.  When I try and display the characters, it displays strange characters.

       

      When I bring the XML into Flex as a String, I do the following:

       

      var xml:XML = new XML(xmlString);

       

      For example the string might be:

       

      <?xml version='1.0' encoding='UTF-8'?>

           <Root>

                <MASTERWINEINDEX>

                     <Col name="DESIGNATION"><![CDATA[Et Côteras]]></Col>

                     <Col name="VINTAGE"><![CDATA[2006]]></Col>

                </MASTERWINEINDEX>

           </Root>

       

      I use the following to display in an AdvancedDataGrid:

       

      private function wineSearchLabelFunction(item:XML, column:AdvancedDataGridColumn):String {

           return item.Col.(@name==column.dataField).toString();

      }

       

       

      <mx:AdvancedDataGrid id="dataWineGrid" designViewDataType="flat" top="42" bottom="75" left="10" right="36"

                 sortableColumns="true" scroll="this.lblTop.text = String(dataWineGrid.verticalScrollPosition)"

                 doubleClickEnabled="true">

           <mx:columns>

                <mx:AdvancedDataGridColumn dataField="DESIGNATION" headerText="Designation" labelFunction="wineSearchLabelFunction"

                                       sortCompareFunction="{function(obj1:XML, obj2:XML):int{return wineSortFunction(obj1, obj2, 'DESIGNATION');}}"/>

            </mx:columns>

      </mx:AdvancedDataGrid>

       

      What I get in the "Designation" column is a field with strange characters.  I'm guessing that it is encoded correctly, but not displaying correctly.  I've tried displaying the data in a TextArea, TextInput and to no avail.

       

      Any ideas?

       

      Is it possible that blazeDS is doing some translation?  When I parse the xml string using "new XML(string)", do I need to do something special?

       

      Thanks,

      Tom