some problem with chinese attribute table

Jan 6, 2011 at 6:25 AM
Edited Jan 6, 2011 at 9:22 AM

1) The dotspatial has some problem with reading the attribute table with chinese character. How to solve it?

2)How to change the lagend context menu strip? I want to use my own right mouse pop up menu.

 

Developer
Jan 6, 2011 at 2:45 PM
Write test case
Write unit test
modify code until test works.

On Wed, Jan 5, 2011 at 11:25 PM, BruceAiden <notifications@codeplex.com> wrote:

From: BruceAiden

The dotspatial has some problem with reading the attribute table with chinese character. How to solve it?

Read the full discussion online.

To add a post to this discussion, reply to this email (DotSpatial@discussions.codeplex.com)

To start a new discussion for this project, email DotSpatial@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Mar 15, 2011 at 2:08 PM

Bruce,do you solve the chinese attribute table problem?

I have the same problem.

This problem is caused because the character encoding. Need the support ofUTF8 or GB2312?

Mar 21, 2011 at 4:44 PM
what i used vfpoledb to read the dbf table and display it in datagridview. i hope that can help you.

2011/3/15 xunzi81 <notifications@codeplex.com>

From: xunzi81

Bruce,do you solve the chinese attribute table problem?

I have the same problem.

This problem is caused because the character encoding. Need the support ofUTF8 or GB2312?

Read the full discussion online.

To add a post to this discussion, reply to this email (DotSpatial@discussions.codeplex.com)

To start a new discussion for this project, email DotSpatial@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Mar 24, 2011 at 2:28 AM

 

 fix chinese attribute ;

 

http://dotspatial.codeplex.com/workitem/197 

 

 

 

Jun 29, 2011 at 8:08 AM

There is also something wrong with chinese attribute table using above method, Does any one solve this problem?

Nov 25, 2011 at 12:43 PM

I have recompiled the code based on the DotSpatial_b5f6bf5fc36c version, and solved this problem.

the key points lie in dotspatial.data.attributetable.cs,where the codes do the Encoding operation, Like this:

    // read the data.

 

    char[] cBuffer = new char[currentField.Length];
    byte[] bBuffer = new byte[currentField.Length];//xkl
    //Array.Copy(_characterContent, start, cBuffer, 0, currentField.Length);//origin code
    Array.Copy(_byteContent, start, bBuffer, 0, currentField.Length); //xkl
    Encoding.Default.GetChars(bBuffer,0, currentField.Length, cBuffer, 0); //xkl

the origin code simply doing a array.copy job, howerver, the "currentfield.length" refers not to the numbers of chars but the numbers of bytes . when we try to extract the value of a field in the datarow encoded with multiple bytes, there will be a wrong offset.

So my way to solve this problem is encoding the data field by field , not row by row, this will lead to a correct offset.

 

Developer
Nov 28, 2011 at 10:07 PM

This thread seems to contain more than one thread.

To help with the question about context menus, you may find \DotSpatial\DotSpatial.Plugins.TableEditor\TableEditorPlugin.cs helpful.

 void Map_LayerAdded(object sender, LayerEventArgs e)
        {
            if (e.Layer == null)
                return;

            const string name = "Attribute Table Editor";
            if (e.Layer.ContextMenuItems.Exists(item => item.Name == name))
            {
                // assume menu item already exists. Do nothing.
                return;
            }

            // add context menu item.
            var menuItem = new SymbologyMenuItem(name, delegate { ShowAttributes(e.Layer as IFeatureLayer); });
            menuItem.Image = Resources.table_16x16;
            e.Layer.ContextMenuItems.Insert(2, menuItem);
        }