J
jeanlutrin
Hi all,
To obtain a byte[] in the UTF-8 encoding from a String
object, I use a getBytes("UTF-8").
This is cumbersome...
Firstly, it is error prone (I mistakenly wrote "UTF-9"
just today, which more or less decided me to post this
message).
Secondly, I'm forced to catch an "unsupported encoding"
exception. Which is completely dumb, as every J2SE JVM
is forced, by the specs, to offer the UTF-8 encoding.
So, I'd like to have a method getBytesUTF8Encoded() in
the String class. Without parameter, without the need
to catch a non-sense exception (a method returning
directly "UTF-8", without needing to pass a prone-to-
error string parameter, would not be able to throw
an UnsupportedEncodingException).
So:
getBytesUTF8Encoded()
getUTF8Bytes()
Whatever.
But something else than the current cumbersome and
prone to error getBytes("UTF-8") throwing a phantom
UnsupportedEncodingException.
Your thoughts on this?
Jean
P.S: I'm not against adding getBytesISOLatin1() method
etc., as long as it's for encoding *mandatory by the
specs* to be in the JVM.
To obtain a byte[] in the UTF-8 encoding from a String
object, I use a getBytes("UTF-8").
This is cumbersome...
Firstly, it is error prone (I mistakenly wrote "UTF-9"
just today, which more or less decided me to post this
message).
Secondly, I'm forced to catch an "unsupported encoding"
exception. Which is completely dumb, as every J2SE JVM
is forced, by the specs, to offer the UTF-8 encoding.
So, I'd like to have a method getBytesUTF8Encoded() in
the String class. Without parameter, without the need
to catch a non-sense exception (a method returning
directly "UTF-8", without needing to pass a prone-to-
error string parameter, would not be able to throw
an UnsupportedEncodingException).
So:
getBytesUTF8Encoded()
getUTF8Bytes()
Whatever.
But something else than the current cumbersome and
prone to error getBytes("UTF-8") throwing a phantom
UnsupportedEncodingException.
Your thoughts on this?
Jean
P.S: I'm not against adding getBytesISOLatin1() method
etc., as long as it's for encoding *mandatory by the
specs* to be in the JVM.