| When creating a shapefile, If the field name contains Chinese, then the display is incorrect. such as :
final SimpleFeatureType TYPE = DataUtilities.createType("Location",
"the_geom:Point:srid=4326," +
"坐标:String"
);
When I debug the code, I found out where the problem might be. In DbaseFileHeader*class's writeHeader function :
for (int j = 0; j < 11; j++) {
if (fields[i].fieldName.length() > j) {
buffer.put((byte) fields[i].fieldName.charAt(j));
} else {
buffer.put((byte) 0);
}
}
in the (byte) fields[i].fieldName.charAt (j), for the Chinese characters, it is incorrect conversion.
String str = "点";
byte[] bytes = str.getBytes();
for(int i=0;i<bytes.length;i++)
{
System.out.println(bytes);
}
char chars = '点';
byte[] bytes = {(byte)chars};
for(int i=0;i<bytes.length;i++)
{
System.out.println(bytes);
}
The result is different. |