Hi Chris,

On Mon, Feb 10, 2020 at 10:59 PM Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> All,
>
> I've recently begun making a change to my application's resource
> bundles, converting them into UTF-8 for readability and converting
> them to ISO-8859-1 during my build process to make ResourceBundle happy.
>

I guess you use Java 8.
Newer versions of Java try UTF-8 first and then fallback to ISO-8859-1:
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/PropertyResourceBundle.html

API Note:
PropertyResourceBundle can be constructed either from an InputStream or a
Reader, which represents a property file. Constructing a
PropertyResourceBundle instance from an InputStream requires that the input
stream be encoded in UTF-8. By default, if a MalformedInputException
<https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/charset/MalformedInputException.html>
 or an UnmappableCharacterException
<https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/charset/UnmappableCharacterException.html>
 occurs on reading the input stream, then the PropertyResourceBundle instance
resets to the state before the exception, re-reads the input stream in
ISO-8859-1, and continues reading. If the system property
java.util.PropertyResourceBundle.encoding is set to either "ISO-8859-1" or
"UTF-8", the input stream is solely read in that encoding, and throws the
exception if it encounters an invalid sequence. If "ISO-8859-1" is
specified, characters that cannot be represented in ISO-8859-1 encoding
must be represented by Unicode Escapes as defined in section 3.3 of The
Java™ Language Specification whereas the other constructor which takes a
Reader does not have that limitation. Other encoding values are ignored for
this system property. The system property is read and evaluated when
initializing this class. Changing or removing the property has no effect
after the initialization.


>
> I have everything working, except that Eclipse still thinks that my
> files ought to be ISO-8859-1 and ruins them when I load them.
> Sometimes, it's very obvious and that's not a problem: a developer
> will see that and fix it before continuing. But some files are only
> *slightly* broken by this and someone might make a mistake.
>
> NOTE: We don't keep Eclipse settings in revision-control, so I can't
> modify everyone's Eclipse configuration. We are using svn and
> svn:mime-type is correctly set for these files; Eclipse just ignores tha
> t.
>
> Anyway, I found that adding a UTF-8 BOM to the beginning of the file
> fixes that issue and Eclipse does the right thing.
>
> As a sanity check. I looked at how Tomcat's files are laid-out and I
> don't see any BOMs.
>
> Should we add BOMs? Is there any reason NOT to use a BOM? These are
> file types that are officially supposed to be ISO-8859-1 but everyone
> wants to handle them differently, so I think adding BOMs might be a
> good idea so that editors are always informed of exactly what's happenin
> g.
>
> WDYT?
>

I don't use Eclipse so I cannot help you with that.
My gut feeling says: If it ain't broken then don't fix it. If no one
complained so far then probably such kind of improvement is not worth it.



>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5BxBIACgkQHPApP6U8
> pFguIw//aJRuOHxjeNX5/Fh981aG3Vajr0+W3PvBFuF85WpNtGAHGA/V2uCy7uY3
> arZBGrE9HvLu0m+1ezs2oB9/craJogOIm/H7n5nDHDAk+Y9S6IIvookTXUIQrMH/
> Eqqv4FWfJpHQKj4jE43nWR6SyJsll7TZ3GJ5jwnq4DpcZodSsyzneKchyys14YTp
> 7+zALlaVZV4+82aAbFPc6Z3WIiHCNXrHrixYOLgq6XZ8hwS7TP//vMTkMn8Rq1CW
> HJZ6k09+KLWTeMbPPUdbqFj8znl3UIbUSgx2Jq/MxNqZikBoiV9WYDAgFFNkA3OW
> VOSNdLSmHqx+mAz3l2LaVXItb8cdHoK/zhRvzwYpq6oslApOcgn9ZQBxPBsmjx/8
> PfyIUK7dnz3YO3fPBXEXtn9KyZ5lj98iarMPby2WIHJq1KJNslMUuAFTX9k6vL/1
> WTcmF1VOfdBraWRhTZL5m9e48WIYXD1/jl+Px+R5MKRpBXgyKOIAZiAE/k2NsDsC
> bsl1ua0ITpuVqeCXRdqn8YsBh8yBmFW35Z+5QDPoxM6o5A7EKirzAW8ILBGRZoGT
> 7HGFdW1/47vbSRztzInzKUvUAg0jtNVy9Yt8S+/mQfm2mlbqtKrHrjN+nqi9mh/H
> SYe3kJRFgNTXIBLds847vZwOXoq+wtpOps5uTRUPAWjuzL1Rt+8=
> =srFY
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

Reply via email to