[fdo-users] FDO OGR 3.6+3.7 and UTF-8 problem

Hans Milling hm at geograf.dk
Fri Jan 6 07:57:55 EST 2012


Hi everyone

I need some help. I have problems with none ascii characters with FDO OGR
and MGOS2.2.
The strings on the map like road names are all messed up if they contain a
danish letter like Æ Ø Å.
A city name like "Farsø" is suddently written "Fars؀".
I have created a small test program (see code below) to test the problem,
and FDO 3.3 does not have any issues, but FDO 3.6 and 3.7 seems to have this
issue. To me the ISO-8859-1 string read from the TAB file is converted to
UTF-8 at some point, and that messes up the text. See this image for the
output:
http://osgeo-org.1803224.n2.nabble.com/file/n7158330/FDO.png 
Road name: "Bakkegårdsvej", the å character (number 197 or 0xc5) is treated
as unicode (3 bytes) and thus the following "rd" letters are included to
create a Chinese character resulting in "Bakkeg岤svej".
Does anyone have a fix for this, can I recompile FDO ine some way to not
make this error?
I think FDO should know/detect the format of the strings from the source, so
that these are not destroyed.

Test program follows:
---SNIP START---
using System;
using System.Collections.Generic;
using System.Text;
using OSGeo.FDO;
using OSGeo.FDO.Connections;
using OSGeo.FDO.Commands.Schema;
using OSGeo.FDO.Commands.Feature;
using OSGeo.FDO.Schema;

namespace FDO_OGRTest
{
  class Program
  {
    static void Main(string[] args)
    {
      OSGeo.FDO.IConnectionManager mConnMgr =
OSGeo.FDO.ClientServices.FeatureAccessManager.GetConnectionManager();
      // Once you know the provider you want to create a connection for, you
call CreateConnection on the ConnectionManager for the specific provider
named. 
      IConnection mProvConn = mConnMgr.CreateConnection("OSGeo.OGR.3.3");
      // From the connection, you can get the connection Info object which
has the list of connection parameters. This varies depending on the
provider.
      IConnectionInfo connInfo = mProvConn.ConnectionInfo;
      IConnectionPropertyDictionary connPropDict =
connInfo.ConnectionProperties;
      connPropDict.SetProperty("DataSource", "C:\\fdotest\\Address.tab");
      connPropDict.SetProperty("ReadOnly", "TRUE");
      // Once you are done setting the connection parameters, open the
connection
      mProvConn.Open();
      // From that point on, you can create commands to described the schema
      IDescribeSchema schemaCmd =
mProvConn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_DescribeSchema)
as IDescribeSchema;
      FeatureSchemaCollection schemaCol = schemaCmd.Execute();
      // Or select/update/delete the data or to retrieve the schema.
      ISelect selCmd =
(ISelect)mProvConn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Select);
      selCmd.SetFeatureClassName("Address");
      IReader myReader = selCmd.Execute();
      if (myReader.ReadNext())
      {
        string name = myReader.GetString("Roadname");
        Console.WriteLine("Roadname:" + name);
      }
    }
  }
}
---SNIP END---

Best regards Hans Milling...

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/FDO-OGR-3-6-3-7-and-UTF-8-problem-tp7158330p7158330.html
Sent from the FDO Users mailing list archive at Nabble.com.


More information about the fdo-users mailing list