|
|
| 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 |
| Did you check the encoding of the string you get back from the database? Also, I thought strings were always UTF-16 |
| Unless otherwise specified. |
| 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 |
| Strings in java memory are always utf-16 |
| But if you create one with another encoding from bytes, doesn't it transcode it to UTF-16 in memory? |
| Yes... But who cares how it's stored? |
| So if you create a string by passing bytes and the appropriate encoding, then do .getBytes() won't that return the UTF-16 bytes? |
| Booleans could be stored as 32-bit values. |
| Or does it return the original? |
| ovigo22, no, it'll transcribe it to the encoding specified. |
| ovigo22, getBytes(String encoding) |
| Kopilman, you're certain of that? |
| ovigo22, Yes. I am. |
| ovigo22, .getBytes() without parameters switches to the system defaults |
| Ok System default But not the one used when creating the string |
| In my case it seems to |
| Nope. Well, it could be, it's just not guarenteed to be. |
| 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 |
| 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 |
| Yes but at least you would have some insight instead of relying on simply an imaginary contract for what to deal with |
| jomanda, we still have not seen any test case... |
| I tried <form enctype="...">, but it does not work |
| 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 |
| Any idea how to enforce encoding for post, then? |
| jomanda,http://www.w3schools.com/tags/tag_form.asp accept= and perhaps accept-charset= .. I don't know for sure, as I've never had to deal with it. |
| Cyberea, yeah.. at first reading i misunderstood them and i thought they are for browser, not server ;) |