Understanding character encoding in typical Java web app
Posted
by Marcus
on Stack Overflow
See other posts from Stack Overflow
or by Marcus
Published on 2010-03-28T20:19:13Z
Indexed on
2010/03/28
20:23 UTC
Read the original article
Hit count: 207
Some pseudocode from a typical web app:
String a = "A bunch of text"; //UTF-16
saveTextInDb(a); //Write to Oracle VARCHAR(15) column
String b = readTextFromDb(); //UTF-16
out.write(b); //Write to http response
In the first line we create a Java String
which uses UTF-16.
When you save to Oracle VARCHAR(15) does Oracle also store this as UTF-16? Does the length of an Oracle VARCHAR refer to number of Unicode characters (and not number of bytes)?
And then when we write b
to the ServletResponse
is this being written as UTF-16 or are we by default converting to another encoding like UTF-8?
© Stack Overflow or respective owner