-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Joe,
Russo, Joe wrote:
> Of course, the existing data that is stored incorrectly can not be
> viewed correctly. I thought by changing the filter you sent by
> interrupting the charset as ISO-8859-1 for the response would work
> correctly.
No, the problem is that your application thinks that the data in the DB
is in UTF-8 format, but it's not. Here's what you have to do:
1. Identify the rows that need to be "fixed".
2a. Run a query that reads the data as bytes (not characters), and then
cast it to UTF-8 character data, then write it back.
2b. Write a little Java program to read the data as bytes (not chars),
convert to a String using the suspected encoding (UTF-8, right?),
and then writing it back to the database.
This ought to work, but might be kind of a pain in the neck. Of course,
always test that things are working the way you expect them to before
you COMMIT anything ;)
I would recommend using a Java program. Write a quick test like this:
SELECT my_data ... WHERE ... FOR UPDATE
ResultSet rs = ...;
InputStream in = rs.getBinaryStream("my_data");
int count = 0;
String s = "";
byte[] bytes = new byte[1024];
while(0 <= (c = in.read(bytes))
s = s + new String(bytes, 0, c, "ISO-8859-1"); // or whatever
System.out.println("Read string from database: " + s);
rs.updateString("my_data", s);
rs.close();
SELECT my_data ... WHERE ...
s = rs.getString("my_data");
System.out.println("Read fixed string from database: " + s);
conn.rollback();
Make sure that your terminal is configured to properly display UTF-8
character data, or that you have some other good way of determining that
the test output is correct.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGwKpM9CaO5/Lv0PARAnjeAKCbLF9KK2gkaVTE0yjbs6YMPRfFUACfUjAR
SIPO2gjeAzdwK8iUreSF3uY=
=FKXu
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]