[Fwd: [PATCH?] Fix for german umlaut problem in style files]

Hi! As I tried to follow the guide at: http://wiki.openstreetmap.org/wiki/DE:All_in_one_Garmin_Map I stumbled over the following mkgmap error: Error in style: Error: (points:68): Invalid operation 'V' at top level After communicating this on osm talk-de, I recognized that this problem only seem to appear on Windows but works fine on Linux. The problematic style line: cuisine = kebap | cuisine = döner [0x2a19 resolution 24] contains a german umlaut ö (don't know if this char will be mangled by the mail transfer). The style file itself is an UTF-8 (without BOM) formatted file. I tried to convert the file to different character encodings, but always get the above error. As far as i understand this, its a problem of the character encoding for style files. I've tried to tell mgkmap to use UTF8 from command line -Dfile.encoding=UTF8 only getting an "unrecognized option" error. Then I digged deeper into the source code ... The attached patch fixes the problem on my Windows XP german machine. It tells JAVA to read the stylefile always in UTF-8 format, which is IMHO a good idea anyway ... This is the first time I looked into the mkgmap code, so I don't know if this patch will make problems on Linux, if it fixes the problem in all style cases and very certainly has a very ugly Exception handling. Couly someone have a look at it? Regards, ULFL Index: src/uk/me/parabola/mkgmap/osmstyle/DirectoryFileLoader.java =================================================================== --- src/uk/me/parabola/mkgmap/osmstyle/DirectoryFileLoader.java (revision 987) +++ src/uk/me/parabola/mkgmap/osmstyle/DirectoryFileLoader.java (working copy) @@ -20,6 +20,9 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; +import java.io.InputStreamReader; +import java.io.FileInputStream; +import java.io.UnsupportedEncodingException; import java.io.Reader; import java.util.ArrayList; import java.util.List; @@ -53,7 +56,14 @@ */ public Reader open(String filename) throws FileNotFoundException { File file = new File(dir, filename); - Reader r = new FileReader(file); + + Reader r = null; + try { + r = new InputStreamReader(new FileInputStream(file), "UTF-8"); + } + catch(UnsupportedEncodingException uee) { + System.out.println("DirectoryFileLoader: Encoding UTF-8 not supported"); + } return new BufferedReader(r); }
participants (1)
-
Ulf Lamping