Subject Re: Which charset to use?
Author personalsoft_fabiano
--- In, "Roman Rokytskyy" <roman@...> wrote:
> > My database uses mostly ISO-8859-1 charset on varchar fields.
> >
> > Which charset should i use to connect to the database to have the
> > accents written correctly in the database?
> >
> > I suppose despite the platform the app will run from, all Java strings
> > uses UTF-16 charset, so i should connect to the database using UTF-8,
> > is it right?
> You can use either UTF-8 or ISO-8859-1 charsets. Both will work and
> should be no noticable performance penalty, though ISO-8859-1 might be
> slightly faster.
> Roman

Ok, thank you.

Just to make sure, if i have a text file with a SQL statement encoded
in ISO-8859-1 and i read it into a java String using:

BufferedReader r = new BufferedReader(fileStream, "ISO-8859-1"));
String sql = reader.readLine();

The file content will be converted to UTF-16 when stored in the
String, and when i execute this statement in the database using:

properties.put("charSet", "UTF-8");


properties.put("charSet", "ISO-8859-1");

The content stored in my database will be correct, so i presume
JayBird will convert the statement String from UTF-16 to the
connection charset before sending it to the server.

Is this the way it works?