Joke Collection Website - Blessing messages - Java garbled problem
Java garbled problem
byte[]b = str . getbytes(" ISO-8859- 1 ");
Generally, the default code is ISO-8859- 1.
The form data submitted by POst generally have Chinese characters.
Before obtaining: request. setcharacterencoding(" gbk ");
Before sending Chinese data: response.setcontenttype ("text/html; charset = GBK ");
For JSP pages, before obtaining the request parameters:
& lt% request . setcharacterencoding(" GB 23 12 ")% & gt;
& lt% @ page contenttype = "text/html; charset = GBK " % & gt;
besides
string name = request . getparameter(" name ");
What you get is garbled code.
Name = new string (name. getbytes ("ISO-8859-1"), "GBK").
The Unicode value of name in the first line here is converted with ISO-8859- 1 encoding. Call the second line to get the original GBK encoding value and reconstruct the Unicode encoding of the string with the new string.
- Previous article:Change the words in the Searle window
- Next article:How does China Post EMS calculate the freight?
- Related articles
- How long does it take to receive SMS for inter-bank and inter-provincial transfer?
- I recently met an online friend and wanted to be friends with me. She gave me her mobile phone number and asked me to send her a message. What kind of message should I convey?
- After breaking up, if the other party doesn't reply, what is the best way to save it?
- On the aestheticism of a girl's heart
- Why does it rain red on my husband's birthday?
- I can't attend the meeting because of the epidemic. How to send WeChat to the leaders?
- Is the Mid-Autumn Festival bank closed?
- When will the latest news of Cangnan epidemic be unsealed?
- Write a diary about something interesting that happened to you when you were a child
- How many days can Jiuquan residence permit receive SMS?