ArcEngine读取ShapeFile时,出现乱码的解决方案

  ArcEngine读取ShapeFile时,如果用LicenseControl的话,字段中含有汉字时可以正常使用,当使用LicenseInitializer进行初始化时,读取含有汉字的字段时,就会出现乱码。

        乱码肯定是由于编码引起的,Google之后,在国外的网站查到DBF的编码格式为固定的ISO8559-1,所以需要做的事是将ISO8559-1的编码转化为gb2312,经测试以上思路确实可行,代码如下:

            IFeature feature = featureCursor.NextFeature();
            if (feature != null)
            {
                string value1 = feature.get_Value(feature.Fields.FindField("NAME99"));
                byte[] temp = Encoding.GetEncoding("ISO8859-1").GetBytes(value1);
                string value2 = Encoding.Default.GetString(temp);
            }

来自:http://www.cfanz.cn/index.php?c=article&a=read&id=80578

原文地址:https://www.cnblogs.com/gisoracle/p/4817294.html