Home  >  Article  >  Java  >  Java text garbled solution

Java text garbled solution

尚
Original
2019-12-17 15:49:363329browse

Java text garbled solution

1. You can set the encoding format of the file in myeclipse, but when we use Scanner to type, since Windows uses GBK encoding, if the encoding format is not GBK There will be problems with Chinese garbled characters.

2. When the front-end page sends a request to the back-end, if it is in get mode, it will be sent in ISO8859-1 format by default, and Chinese garbled characters will also appear.

3. For the above two situations, you can use the following code to solve it:

new String(乱码变量.getBytes("原编码格式"),"现编码格式");

For more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of Java text garbled solution. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn