Last active
December 10, 2019 06:17
-
-
Save zhanggang807/4306eb8a820ad812bb70876aabe75018 to your computer and use it in GitHub Desktop.
JDK Charset test
This file contains 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
public static void main(String[] args) { | |
//Charset unnderline = Charset.forName("utf_8");//无效 | |
Charset big = Charset.forName("UTF-8"); | |
Charset small = Charset.forName("utf-8"); | |
Charset no1 = Charset.forName("utf8"); | |
Charset no2 = Charset.forName("UTF8"); | |
//上边这四个编码 相同的效果,看来jdk内部会处理大小写和有无短横线的问题 | |
// sun.nio.cs.FastCharsetProvider#lookup 有转换为小写的方法 | |
// sun.nio.cs.UTF_8 这个类是真正的实现类 | |
//System.out.println(unnderline); | |
System.out.println((big == small)); | |
System.out.println(big); | |
System.out.println(small); | |
System.out.println(no1); | |
System.out.println(no2); | |
System.out.println(big.aliases()); | |
System.out.println(big.displayName()); | |
System.out.println(big.name()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment