| View previous topic :: View next topic |
| Author |
Message |
jomanda
Joined: 19 May 2006 Posts: 70 Location: Germany
|
Hi! i have a problem. if i reply the string to the browser without any changes, it does not work. what is that?
BUT, if i do the getBytes() trick, and i store and read it from db, it does display correctly |
| |
|
|
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
Did you check the encoding of the string you get back from the database?
Also, I thought strings were always UTF-16 |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
| Unless otherwise specified. |
| |
|
|
jomanda
Joined: 19 May 2006 Posts: 70 Location: Germany
|
i think, that db read/write trick helps only as conversion from byte[] to String all my db communication seem to be iso-8859-2, and i see no problems with it |
| |
|
|
PaulKolin
Joined: 25 May 2006 Posts: 108
|
| Strings in java memory are always utf-16 |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
| But if you create one with another encoding from bytes, doesn't it transcode it to UTF-16 in memory? |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
Yes...
But who cares how it's stored? |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
| So if you create a string by passing bytes and the appropriate encoding, then do .getBytes() won't that return the UTF-16 bytes? |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
| Booleans could be stored as 32-bit values. |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
| Or does it return the original? |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
| ovigo22, no, it'll transcribe it to the encoding specified. |
| |
|
|
|
|
PaulKolin
Joined: 25 May 2006 Posts: 108
|
| ovigo22, getBytes(String encoding) |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
| Kopilman, you're certain of that? |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
| ovigo22, Yes. I am. |
| |
|
|
jomanda
Joined: 19 May 2006 Posts: 70 Location: Germany
|
| ovigo22, .getBytes() without parameters switches to the system defaults |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
Ok
System default
But not the one used when creating the string |
| |
|
|
jomanda
Joined: 19 May 2006 Posts: 70 Location: Germany
|
| In my case it seems to |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
Nope.
Well, it could be, it's just not guarenteed to be. |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
Right, which means it's not
It has no relevance, but could coincidentally be the same (obviously)
jomanda, you should look at the tomcat source code to see how it's encoding the strings
Maybe it's doing it incorrectly
Or differently than seems appropriate or correct |
| |
|
|
jomanda
Joined: 19 May 2006 Posts: 70 Location: Germany
|
I think, that the chances are that i am doing something wrong
Btw. i am not able to enforce browser to specify iso-8859-2 on post |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
| Yes but at least you would have some insight instead of relying on simply an imaginary contract for what to deal with |
| |
|
|
|
|
PaulKolin
Joined: 25 May 2006 Posts: 108
|
| jomanda, we still have not seen any test case... |
| |
|
|
jomanda
Joined: 19 May 2006 Posts: 70 Location: Germany
|
| I tried <form enctype="...">, but it does not work |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
jomanda, enctype isn't for the encoding, but for the post data format
I.e. application/x-form-urlencoded vs. whatever else
You have to specify a non-default for say, file uploads |
| |
|
|
jomanda
Joined: 19 May 2006 Posts: 70 Location: Germany
|
| Any idea how to enforce encoding for post, then? |
| |
|
|
| Page 1 of 2 |
Goto page 1, 2 Next |
|