JAVA字符编码测试
几点注意:
1,ASCII码和ISO-8859-1都是单字节编码,ASCII码能表示128个字符,ISO-8859-1总共能表示256个字符。都不能表示中文,如果中文字符或其它不在IOS-8859码值范围内的字符会统一用3f表示(显示为"?", 通常所说的"黑洞");
2,GBK兼容GB2312,是双字节编码,GB2312包含6763个汉字,GBK包含21003个汉字;
3,UTF-16为定长双字节编码,大大简化了字符串的操作,但是会浪费存储空间。JAVA以UTF-16作为内存存储格式(见编码测试输出source行);
4,UTF-8采用变长,不同类型的字符可以由1~6个字节组成(汉字一般3个字节)。UTF-8规则如下:
- 如果是1个字节,最高位(第8位)为0,则表示这是1个ASCII字符(00~7F)。可见,所有的ASCII编码已经是UTF-8了。
- 如果是1个字节,以11开头,则连续的1的个数暗示这个字符的字节数,例如:110xxxxx代表它是双字节UTF-8字符的首字节。
- 如果是1个字节,以10开头,表示它不是首字节,则需要向前查找才能得到当前字符的首字节。
测试代码:
package com.test.main; public class TestCode { public static void encode(){
String name = "淘!我喜欢!";
toHex(name.toCharArray());
String [] codeType = {"ISO-8859-1", "GB2312", "GBK", "UTF-16", "UTF-8"};
for (String type : codeType) {
try {
byte [] bytes = name.getBytes(type);
toHex(type, bytes);
} catch (Exception e) {
e.printStackTrace();
}
}
} private static void toHex(String name, byte[] charArray) {
System.out.print(String.format("%-15s", name + ":"));
for (int i = 0; i < charArray.length; i++) {
System.out.print(String.format("%-4x ", charArray[i]));
}
System.out.println();
} private static void toHex(char[] charArray) {
System.out.print(String.format("%-15s","source:"));
for (int i = 0; i < charArray.length; i++) {
System.out.print(String.format("%-4x ", (int)charArray[i]));
}
System.out.println();
}
public static void main(String[] args) {
encode();
} }
输出:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA7oAAACBCAIAAABhM1HJAAAXgUlEQVR4nO2d3bXrIA5Gp6V58FrTRzpxJakknaSS08Q85A+EJOPEEuRm76dzgmNkIcRnjMN//rv8bwEAAAAAAI3/IJcBAAAAACyQy/8O6+Xv77LuLdr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LMiNJKz/tYExRaxo2pgjkJtjlChqlnxwmlxe5rFmf+kAuL0uzALy5+7fbK8wG0Vxpo11hhvGqrB1RYZYo1eUs8/IbZbM3RxkiH6IJAi2Zoae4cZgXok5PmaRRqs/zeqsxrGX3E7WetA47R0+p3XE6X+swyPKGaYZ0UnSoMqaYhowbU0qkXAYAAAAAgCfIZQAAAAAAE+QyAAAAAIAJchkAAAAAwAS5DAAAAABgglwGAAAAADBBLgMAAAAAmCCXAQAAAABMkMsAAAAAACbIZQAAAAAAE+QyAAAAAIAJchkAAAAAwAS5DAAAAABgglwGAAAAADBBLgMAAAAAmPwf29xR8laU6yMAAAAASUVORK5CYII=" alt="" />
JAVA字符编码测试的更多相关文章
- 【JAVA编码】 JAVA字符编码系列二:Unicode,ISO-8859,GBK,UTF-8编码及相互转换
http://blog.csdn.net/qinysong/article/details/1179489 这两天抽时间又总结/整理了一下各种编码的实际编码方式,和在Java应用中的使用情况,在这里记 ...
- JAVA字符编码二:Unicode,ISO-8859,GBK,UTF-8编码及相互转换
第二篇:JAVA字符编码系列二:Unicode,ISO-8859-1,GBK,UTF-8编码及相互转换 1.函数介绍 在Java中,字符串用统一的Unicode编码,每个字符占用两个字节,与编码有 ...
- 【字符编码】Java字符编码详细解答及问题探讨
一.前言 继上一篇写完字节编码内容后,现在分析在Java中各字符编码的问题,并且由这个问题,也引出了一个更有意思的问题,笔者也还没有找到这个问题的答案.也希望各位园友指点指点. 二.Java字符编码 ...
- Java 字符编码归纳总结
String newStr = new String(oldStr.getBytes(), "UTF-8"); java中的String类是按照unicode进行编码的 ...
- 【JAVA编码专题】 JAVA字符编码系列三:Java应用中的编码问题
这两天抽时间又总结/整理了一下各种编码的实际编码方式,和在Java应用中的使用情况,在这里记录下来以便日后参考. 为了构成一个完整的对文字编码的认识和深入把握,以便处理在Java开发过程中遇到的各种问 ...
- 【JAVA编码专题】JAVA字符编码系列一:Unicode,GBK,GB2312,UTF-8概念基础
这两天抽时间又总结/整理了一下各种编码的实际编码方式,和在Java应用中的使用情况,在这里记录下来以便日后参考. 为了构成一个完整的对文字编码的认识和深入把握,以便处理在Java开发过程中遇到的各种问 ...
- Java 字符编码(二)Java 中的编解码
Java 字符编码(二)Java 中的编解码 java.nio.charset 包中提供了一套处理字符编码的工具类,主要有 Charset.CharsetDecoder.CharsetEncoder. ...
- Java 字符编码(三)Reader 中的编解码
Java 字符编码(三)Reader 中的编解码 我们知道 BufferedReader 可以将字节流转化为字符流,那它是如何编解码的呢? try (BufferedReader reader = n ...
- Java 字符编码(一)Unicode 字符编码
Java 字符编码(一)Unicode 字符编码 Unicode(http://www.unicode.org/versions/#TUS_Latest_Version) 是一个编码方案,说白了希望给 ...
随机推荐
- php实现socket简单的例子
一.Socket简介 1.socket只不过是一种数据结构 2.使用这个socket数据结构去开始一个客户端和服务器之间的会话 3.服务器是一直在监听准备产生一个新的会话.当一个客户端连接服务端,它就 ...
- ajax1—php(27)
一 简介 web程序工作原理图: 传统的web程序工作原理图: Ajax工作原理图: 1. 关于Ajax l Asynchronous 异步 l JavaScript l And l XML ...
- “全栈2019”Java第一百零八章:匿名内部类与final关键字
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...
- IDEA中配置SpringMVC框架 第一个演示【转】
环境: intellij IDEA 2017 CI JDK 1.8 tomcat 8.5.23 具体步骤 1.新建项目 勾选Spring MVC .Web Application(勾选了Spring ...
- Python FLask Web 学习笔记:jinjia2的使用方法1
# coding:utf-8 from jinja2 import Template x = """ <p>大爷的孙子</p> <ul> ...
- spring管理hibernate session的问题探究
我们再用spring管理hibernate的时候, 我们会继承HibernateDaoSupport 或者HibernateTemplate类. 我们不知道这两个类之间有什么关系. 也没有去关闭ses ...
- [Flex] 组件Tree系列 —— 运用variableRowHeight和wordWrap设置可变行高
mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:运用variableRowHeig ...
- ps与grep组合命令使用
管道命令 我们在做运维的时候,经常会使用这个命令ps -ef | grep nginx. ps -ef 表示显示所有进程的消息. | 是管道命令.通常需要借助管道命令”|”多个命令的组合,形式如下: ...
- [译文]casperjs的API-mouse模块
mouse类 这个类是对各种鼠标操作的抽象,比如移动,点击,双击,滚动等.它要求一个已经获得DOM属性的casper对象,能用这种方式创造一个鼠标对象: var casper = require(&q ...
- Linux服务器核心参数配置
使用Linux作为长连接的web服务器时,为了增加服务的容量,以及处理性能,需要修改一些参数. 一.多进程绑定CPU 1.使用taskset命令可以绑定进程到指定CPU,以减少多核CPU环境中,单进程 ...