> I don't think your Java code does what you think it does. You should
> read some more about how Java handles string encodings. Here is a method
> I wrote some years ago that might also help you. It converts streams,
> not strings, but what you need should be pretty close (and simpler):
> /**
> * Interprets in according to encIn, and converts it to encOut,
> * writing to out. Allocates buffer for the buffer size.
> * @param encIn The input encoding.
> * @param encOut The output encoding.
> * @param in The data to convert.
> * @param out Where to send the converted data.
> * @param buffer The size of the buffer or 0 for the default.
> * @throws IOException
> */
> public void run(String encIn, String encOut, InputStream in,
> OutputStream out, int buffer) throws IOException {
> Reader r = null;
> Writer w = null;
> int len;
> char[] b;
> try {
> if (buffer > 0) {
> r = new BufferedReader(new InputStreamReader(in, encIn), buffer);
> w = new BufferedWriter(new OutputStreamWriter(out, encOut),
> buffer);
> } else {
> r = new BufferedReader(new InputStreamReader(in, encIn));
> w = new BufferedWriter(new OutputStreamWriter(out, encOut));
> buffer = DEFAULT_BUFFER_SIZE;
> }
> b = new char[buffer];
>
> while ((len = r.read(b, 0, buffer)) != -1) {
> w.write(b, 0, len);
> }
> } finally {
> try {
> if (r != null) r.close();
> } finally {
> if (w != null) w.close();
> }
> }
> }
> Btw, none of this has anything to do with Postgres. :-)
Thank you for the code first. I will try it later. The problem I had as
mentioned in the subject is:
(1) psql@utf8
(2) mysql@latin1
When I load data from (1) to (2) through Mybatis, french characters
could not be mapped correctly in (2). I was thinking that psql may have
methods could help this. But it seems that I have to try from java
coding side :-(
--
Emi