> In general you can't. Consider UTF-8. Each character
> encodes as 1,2,3 or 4 bytes!
>
> Of course, any fixed length encoding (e.g.
> ISO-8859-1)is trivial to deal with.
I think, it is not trivial. At first, I don't know, what the charset is. It is trivial if I know that it will always be particular charset, e.g. US-ASCII. For US-ASCII I know, that all characters is one-byte encoded, the first is 0x00 and the last is 0x7F. But if I have not that data, I can only request the average and the maximum bytes per char, and using CharacterEncoder I can test 65536 characters - whether they could be encoded or not.
Message was edited by:
jute