Understanding character encoding in typical Java web app
- by Marcus
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?