Java character encoding conversion

Source: Internet
Author: User

In the process of development, character encoding often gives us headaches. Often there are a variety of garbled characters. The following is the introduction of Java Encoding conversion and common garbled is what encoding to use to read:

First look at a picture:

Look at how the encoded transformation is handled in Java:

Package com.test;/** * String encoding conversion * @author Herman.xiong * @date July 16, 2015 09:36:59 * @version V3.0 * @since tomcat6.0,jdk1.6  * @copyright Copyright (c) */public class Httpserverdecoder {public static void main (string[] args) throws Exception {String str= Welcome to join the request group: 454796847 Learn together! "; System.out.println (str);//Convert to Utf-8 output System.out.println (new String (. GetBytes ("Utf-8"));// Convert to GBK output System.out.println (new string (. GetBytes ("GBK"));//Convert Iso-8859-1 to Utf-8system.out.println (new string ( Str.getbytes ("Iso-8859-1"), "Utf-8");}}

Welcome everyone to follow my blog! If in doubt, please add QQ Group: 454796847 Study together!

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java character encoding conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.