Last active
October 2, 2017 06:56
-
-
Save nobodxbodon/8b7ff2df54b845a5a0851b887f038686 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.nio.charset.StandardCharsets.UTF_8; | |
import java.io.UnsupportedEncodingException; | |
/** | |
* 问题复现: | |
文件编码为UTF-8 | |
控制台编码先为UTF-8: | |
$ javac -encoding utf8 EncodeIssue.java | |
$ java EncodeIssue | |
��?始检查�?��?? | |
控制台编码改为GBK: | |
$ java EncodeIssue | |
寮?濮嬫��鏌モ?︹?? | |
Ubuntu平台编码: | |
$ locale | |
LANG=zh_CN.UTF-8 | |
LANGUAGE=zh_CN:en_US:en | |
LC_CTYPE="zh_CN.gbk" | |
LC_NUMERIC="zh_CN.gbk" | |
LC_TIME="zh_CN.gbk" | |
LC_COLLATE="zh_CN.gbk" | |
LC_MONETARY="zh_CN.gbk" | |
LC_MESSAGES="zh_CN.gbk" | |
LC_PAPER="zh_CN.gbk" | |
LC_NAME="zh_CN.gbk" | |
LC_ADDRESS="zh_CN.gbk" | |
LC_TELEPHONE="zh_CN.gbk" | |
LC_MEASUREMENT="zh_CN.gbk" | |
LC_IDENTIFICATION="zh_CN.gbk" | |
LC_ALL=zh_CN.gbk | |
* | |
*/ | |
public class EncodeIssue { | |
public static void main(String[] args) throws UnsupportedEncodingException { | |
System.out.println( new String("开始检查……".getBytes(UTF_8), "GBK")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment