|
Hi:
When shpfile's text field use Chinese words,then labelLayer show's is wrong.
I find the error in Dotspatial.Data.AttributeTable.cs.
Error function:private DataRow ReadTableRow(int currentRow, long start, char[] characterContent, DataTable table)
Because one Chinese words have 2 bytes. Line 663:Array.Copy(characterContent, start, cBuffer, 0, len); <-- wrong here.
So I modify the codes like this:
/// <summary>
/// Read a single dbase record
/// </summary>
/// <returns>Returns an IFeature with information appropriate for the current row in the Table</returns>
private DataRow ReadTableRow(int currentRow, long start, char[] characterContent, DataTable table)
{
DataRow result = table.NewRow();
for (int col = 0; col < table.Columns.Count; col++)
{
// find the length of the field.
Field currentField = table.Columns[col] as Field;
if (currentField == null)
{
// somehow the field is not a valid Field
return result;
}
// read the data.
char[] cBuffer = new char[currentField.Length];
long len;
if (start + currentField.Length > characterContent.Length)
{
len = characterContent.Length - start;
}
else
{
len = currentField.Length;
}
if (len < 0) return result;
Array.Copy(characterContent, start, cBuffer, 0, len);
////////////////////////////////////modify here///////////////////////////////////////////////////////
int chineseCount = 0;
foreach (char c in cBuffer) {
if ((int)c > 255)
chineseCount++;
}
if (chineseCount > 0){
for (int i = 0; i < chineseCount; i++)
cBuffer[cBuffer.Length - 1 - i] = ' ';
start += currentField.Length - chineseCount;
}
else {
start += currentField.Length;
}
if (IsNull(cBuffer)) continue;
result[currentField.ColumnName] = ParseColumn(currentField, currentRow, cBuffer, table);
}
return result;
}
|