I feel like what you're looking for is really a general-purpose data
transformation API. I think bending charsets into this shape would be
a bad move, but I like the idea of a more generalized solution.
Google Guava has such an abstraction, and I know of a couple of others
a well.
On Thu, May 3,
Well technically there is some sort of precedent to this, since
CharsetEncoder/Decoder operate on CharBuffers which are just utf-16
encoded strings. So charsets already may produce a single output code
*unit* for multiple input code units (UTF-32, which may output 1 code
unit for 2 UTF-16
FYI here’s the javadoc for a draft of the Hex API that Alan mentioned below:
http://cr.openjdk.java.net/~vinnie/8170769/javadoc.05/api/java.base/java/util/Hex.html
Thanks.
> On 2 May 2018, at 10:55, Jonas Konrad wrote:
>
> I did not know about the old HexDumpEncoder. It extends
> On May 2, 2018, at 4:35 PM, Jonas Konrad wrote:
>
> "0a0b0c".getBytes(HexCharset.getInstance()) = new byte[] { 0x0a, 0x0b, 0x0c }
> new String(new byte[] { 0x0a, 0x0b, 0x0c }, HexCharset.getInstance()) =
> "0a0b0c"
Normally a charset is to encode a string to byte[], but here
I did not know about the old HexDumpEncoder. It extends an internal
class `CharacterEncoder` which seems to be pretty similar purpose-wise
to what I am suggesting with CharsetEncoder. There is also the good old
`DatatypeConverter.printHexBinary`, though it can't stream.
But this is not really
On 02/05/2018 09:35, Jonas Konrad wrote:
Hi,
Conceptually, a 'charset' (in java) is a pair of transformations from
bytes to utf-16 code units and vice versa. Could it be useful to have
charset implementations that convert from bytes to the hex (or base64)
representations of those? The idea
Hi,
Conceptually, a 'charset' (in java) is a pair of transformations from
bytes to utf-16 code units and vice versa. Could it be useful to have
charset implementations that convert from bytes to the hex (or base64)
representations of those? The idea is as follows: