[mkgmap-dev] StandardCharsets and try (with-resources)
From Ticker Berkin rwb-mkgmap at jagit.co.uk on Fri Jan 17 12:53:12 GMT 2020
Hi Gerd Attached patch - uses StandardCharsets.* where possible. - notes some usage of the java local DefaultCharset. - changed a couple of these to force utf-8 instead. - if --read-config file gives decoding errors, names the charset used to read the file (ie DefaultCharset) instead of 'utf-8' in the error message. - accepts/ignores unicode BOM in more files - uses try (open...) {} where possible in files changed for the above reasons. There is some code in mkgmap/srt/SrtTextReader.java:sortForCodepage() that I don't understand; it would appear to get into a recursive loop on IOException. Ticker On Tue, 2020-01-14 at 09:55 +0000, Gerd Petermann wrote: > Hi Ticker, > > yes, and every missing close() is a brain teaser ;) > We have a few places where files are opened and closed in a different > method. This is likely to cause trouble in unit tests, esp. on > Windows. > Whereever possible we should use try-with-ressources instead of > Utils.closeFile() and add a comment > like in SeaGenerator line > in zipFile = new ZipFile(precompSeaDir); // don't close here! > when a file is intentionally kept open. > > Gerd > > ________________________________________ > Von: mkgmap-dev <mkgmap-dev-bounces at lists.mkgmap.org.uk> im Auftrag > von Ticker Berkin <rwb-mkgmap at jagit.co.uk> > Gesendet: Dienstag, 14. Januar 2020 10:43 > An: Development list for mkgmap > Betreff: Re: [mkgmap-dev] TYP files and character encoding > > Hi Gerd > > Here is updated patch that closes the file, although I find many > files > in mkgmap that don't have explicit close(), but I presume .finalize() > will close them eventually. > > I'll do another patch for other text file handling, using > StandardCharset where possible and fixing TokenScanner message for > bad > characters if not utf-8 and, if reasonable, allowing a BOM even if > the > file is opened as utf-8 anyway. > > Ticker > > On Tue, 2020-01-14 at 08:21 +0000, Gerd Petermann wrote: > > Hi Ticker, > > > > thanks for the patch. > > > > Please review TypCompiler.CharsetProbe. BufferedReader br is not > > closed. Is that intended? > > > > I see that we have a mix of "utf-8" and "UTF-8" in the mkgmap > > sources. I think it would be good to use StandardCharsets.UTF_8 > > where > > possible > > and unify the rest. -------------- next part -------------- A non-text attachment was scrubbed... Name: utf8.patch Type: text/x-patch Size: 22546 bytes Desc: not available URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20200117/5114fbd0/attachment-0001.bin>
- Previous message: [mkgmap-dev] TYP files and character encoding
- Next message: [mkgmap-dev] StandardCharsets and try (with-resources)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the mkgmap-dev mailing list