-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 04/05/10 22:11, undertow wrote:
> hello, i seem to be having issued with GWT and character encoding. I
> have an Oracle database which stores strings with iso-8859-1
> encoding. GWT does NOT support java's String.getBytes(), nor does it
> support new String(byte[], encoding).
>
> the question is, how do i get the string bytes from the database blob
> to the properly encoded string?
You need to convert the data from ISO-8859-1 to UTF-16 at the point
where your app touches Oracle --- that is, on the server.
GWT supports standard Java strings, which are UTF-16 (i.e. arrays of
16-bit Character values --- note that this is *not* Unicode!), but as
you've found it does support transcoding. Character conversion ideally
only happens when you do I/O on the string, via a Reader or a Writer,
and as all I/O on GWT is supposed to either happen on the server or else
use native Unicode they haven't implemented it.
I have on occasion managed to force non-UTF-16 data into a string, but
strictly only as a hack, and it always causes problems. If Oracle's API
is giving you such a string, then They Are Doing It Wrong...
[As an aside: I have managed to port huge chunks of
java.io and java.nio
to run on GWT client-side, and I've also got the basic framework of
java.nio.charset, so it *is* possible to do character encoding
translation on the client... but I haven't found any sensibly small
encoding codecs yet, so I'm having to write my own slow buggy ones ---
so you probably don't want this approach.]
- --
┌─── dg@cowlark.com ─────
http://www.cowlark.com ─────
│
│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.org/
iEYEARECAAYFAkvhnDMACgkQf9E0noFvlzgkfwCfSgDz12nZN2AOLtiZw6qMh8Xz
yloAoIznv+9JGBozm20a3HDU56+IcL7D
=M+yG
-----END PGP SIGNATURE-----