博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UTF-8 's format
阅读量:6967 次
发布时间:2019-06-27

本文共 2179 字,大约阅读时间需要 7 分钟。

几篇比较好的博客

man ascii可以查看ascii码表,man utf-8看以查看utf-8的帮助

Unicode is a design,it includes all the characters on earth.It just defined the character set,just defined what characters should be included.It didn't define how to express these characters in computer.

UTF-8 is a implementation of Unicode.Its is designed in 1992 by Ken*Tompson(He and Riege created UNIX and C language together).

Unicode in java is 'char',2 bytes.From 0 to 0xffff.

But in UTF-8,different char has different bytes.

Unicode UTF-8 explanation
0000-007F 0xxx xxxx
0080-07FF 110xx xxx    10xx xxxx
0800-FFFF 1110 xxxx   10xx xxxx    10xx xxxx
|  Unicode符号范围      |  UTF-8编码方式   n |  (十六进制)           | (二进制)  ---+-----------------------+------------------------------------------------------   1 | 0000 0000 - 0000 007F |                                              0xxxxxxx   2 | 0000 0080 - 0000 07FF |                                     110xxxxx 10xxxxxx   3 | 0000 0800 - 0000 FFFF |                            1110xxxx 10xxxxxx 10xxxxxx   4 | 0001 0000 - 0010 FFFF |                   11110xxx 10xxxxxx 10xxxxxx 10xxxxxx   5 | 0020 0000 - 03FF FFFF |          111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx   6 | 0400 0000 - 7FFF FFFF | 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx

 

In java,'xxxxReader' is always text input and 'xxxxStream' is always a binary input.Firstly,We use text output 'PrintWriter' to write file.Then we use 'FileInputStream' to read file.Our task is to convert the binary information into Unicode.If what we write is the same with what we read,we can assure we comprehend the UTF-8 format.

 
 

 

 

 

we can use java's library to convert a gbk file to unicode.
class uni {    public static void main(String[] args) throws Exception {        String name=args[0].substring(0,args[0].indexOf("."));        PrintWriter cout = new PrintWriter(new File(name + "-unicode.txt"));        InputStreamReader cin = new InputStreamReader(new FileInputStream(                new File(args[0])), "GBK");        char buf[] = new char[100];        int n = cin.read(buf);        while (n != -1) {            cout.print(buf);            n = cin.read(buf);        }        cin.close();        cout.close();    }}

 

转载地址:http://ixfsl.baihongyu.com/

你可能感兴趣的文章
jQuery learn - 1 - 选择元素 && CSS
查看>>
svn merge
查看>>
pxe和kickstart无人值守安装
查看>>
getGeneratedKeys自动获取主键的方法
查看>>
初来咋到的菜鸟
查看>>
国外设计师眼中的原型工具Mockplus
查看>>
SBIT典型应用
查看>>
我的友情链接
查看>>
Linux下如何执行Shell脚本
查看>>
我的友情链接
查看>>
perl访问sybase等数据库
查看>>
用PhpStorm IDE创建GG App Engine PHP应用教程
查看>>
网络连接、路由配置等
查看>>
立足自主可控 斩获财政局虚拟化大单
查看>>
山寨山寨版手机安全卫士项目
查看>>
Could not find action or result
查看>>
我的友情链接
查看>>
面试相关知识点
查看>>
zenoss core
查看>>
编译nginx时的两个报错
查看>>