We had a a clob column in DB. Now when we extract this clob and try to display it (plain text not html), it prints junk some characters on html screen. The character when directly streamed to a file looks like ” (not the usual double quote on regular keyboard)
One more observation:
System.out.println("”".getBytes()[0]);
prints -108.
Why a character byte should be in negative range ? Is there any way to display it correctly on a html screen ?
Re: your final observation – Java bytes are always signed. To interpret them as unsigned, you can bitwise AND them with an int:
which outputs:
Note that your string is actually three bytes long in UTF-8.
As pointed out in the comments, it depends on the encoding. For UTF-16 you get:
and for US-ASCII or ISO-8859-1 you get
which is a question-mark (i.e. “I dunno, some new-fangled character”). Note that: