[
http://jira.codehaus.org/browse/GEOT-1210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrea Aime reopened GEOT-1210:
-------------------------------
> Encoding problem from shapefile attribute reader
> ------------------------------------------------
>
> Key: GEOT-1210
> URL: http://jira.codehaus.org/browse/GEOT-1210
> Project: GeoTools
> Issue Type: Bug
> Components: data versioning postgis
> Environment: Windows XP SP2 Simplified Chinese version, J2SE 1.5.0_08
> Reporter: Min Feng
> Assignee: Andrea Aime
> Fix For: 2.3.3, 2.4.0
>
> Attachments: danishShape.zip, TestChineseChar.zip,
> TestShapefileDbf.java, wms-chinese.png
>
>
> I try to read my shapefile using GeoTools, but the returned Chinese
> characters from attribute have encoding problem: all the attribute strings
> are encoded into ISO-8859-1 not the right local encoding. I tracked into the
> source codes, and found that the encoding is set to "ISO-8859-1" in
> DbaseFileReader.java:
> 205 charBuffer = CharBuffer.allocate(header .getRecordLength() - 1);
> 206 Charset chars = Charset.forName("ISO-8859-1" );
> 207 decoder = chars.newDecoder();
> However, the default encoding can not be changed, because it may lead to
> wrong record length (each Chinese character occupy two bytes). Finally, I
> added some codes to decode the string type attribute from ISO-8859-1 to local
> encoding (line 449), and it works.
> 443 // set up the new indexes for start and end
> 444 charBuffer .position(start).limit(end + 1);
> 445 String s = charBuffer.toString();
> 446
> 448 // decode string from ISO-8859-1 to default encoding
> 449 s = new String(s.getBytes("ISO-8859-1" ));
> 450
> I hope the codes maybe help for resolving Asian languages encoding problem
> for shapefile dbf reader!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel