https://stackoverflow.com/questions/3951722/whats-the-difference-between-unicode-and-utf-8

If asked the question, "What is the difference between UTF-8 and Unicode?", would you confidently reply with a short and precise answer? In these days of internationalization all developers should be able to do that. I suspect many of us do not understand these concepts as well as we should. If you feel you belong to this group, you should read this ultra short introduction to character sets and encodings.

Actually, comparing UTF-8 and Unicode is like comparing apples and oranges:

UTF-8 is an encoding - Unicode is a character set

A character set is a list of characters with unique numbers (these numbers are sometimes referred to as "code points"). For example, in the Unicode character set, the number for A is 41.

An encoding on the other hand, is an algorithm that translates a list of numbers to binary so it can be stored on disk. For example UTF-8 would translate the number sequence 1, 2, 3, 4 like this:

00000001 00000010 00000011 00000100 

Our data is now translated into binary and can now be saved to disk.

All together now

Say an application reads the following from the disk:

1101000 1100101 1101100 1101100 1101111 

The app knows this data represent a Unicode string encoded with UTF-8 and must show this as text to the user. First step, is to convert the binary data to numbers. The app uses the UTF-8 algorithm to decode the data. In this case, the decoder returns this:

104 101 108 108 111 

Since the app knows this is a Unicode string, it can assume each number represents a character. We use the Unicode character set to translate each number to a corresponding character. The resulting string is "hello".

Conclusion

So when somebody asks you "What is the difference between UTF-8 and Unicode?", you can now confidently answer short and precise:

UTF-8 and Unicode cannot be compared. UTF-8 is an encoding used to translate numbers into binary data. Unicode is a character set used to translate characters into numbers.

所以,在git bash中使用file *命令查看文件格式的时候。显示的结果,首先是编码,然后是字符集

What's the difference between Unicode and UTF-8?的更多相关文章

  1. Unicode和UTF的关系

    目录结构: contents structure [+] 什么是USC UCS的编码方式 Unicode的来源 为什么需要Unicode Unicode的方式 Unicode和UTF UTF和Unic ...

  2. Unicode、UTF-8 和 ISO8859-1

    Unicode.UTF-8 和 ISO8859-1到底有什么区别 1.本文主要包括以下几个方面:编码基本知识,java,系统软件,url,工具软件等. 在下面的描述中,将以"中文" ...

  3. ascii、unicode、utf、gb等编码详解

    很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们看到8个开关状态是好的,于是他们把这称为"字节".再后来,他们又做了一些可以处理这 ...

  4. Unicode 与 UTF 字符标准

    Unicode 国际字符标准(UCS)是一个字符编码系统,它被设计用来支持世界各国不同语言书面文体之间的数据交换.处理以及显示.        Unicode用两个字节表示一个字符.前127个字符与A ...

  5. Unicode、UTF-8 和 ISO8859-1到底有什么区别

    说明:本文转载于新浪博客,旨在方便知识总结.原文地址:http://blog.sina.com.cn/s/blog_673c81990100t1lc.html 本文主要包括以下几个方面:编码基本知识, ...

  6. Delphi7中Unicode,ANSI,UTF编码问题

    注解: ANSI     'American Standard Code for Information Interchange' 美国信息互换标准代码 ANSI的'Ascii'编码 Unicode ...

  7. ASCII、UNICODE、UTF

    在计算机中,一个字节对应8位,每位可以用0或1表示,因此一个字节可以表示256种情况. ascii 美国人用了一个字节中的后7位来表达他们常用的字符,最高位一直是0,这便是ascii码. 因此asci ...

  8. 转载一篇关于unicode字符编码的文章

    很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们认为8个开关状态作为原子单位很好,于是他们把这称为"字节". 再后来,他们又做了一 ...

  9. 趣谈unicode,ansi,utf-8,unicode big endian这些编码有什么区别(转载)

    从头讲讲编码的故事.那么就让我们找个草堆坐下,先抽口烟,看看夜晚天空上的银河,然后想一想要从哪里开始讲起.嗯,也许这样开始比较好…… 很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同 ...

随机推荐

  1. web_custom_request函数做get接口测试

    最近研究了使用loadrunner做接口测试,刚开始一直不成功,后来加了QQ群,遇到大神了,经指导终于成功 下面是具体实例代码: //{"signIOS":1,"sign ...

  2. EOSS V3.0.2 企业运营支撑系统(基于RBAC原理的权限管理)

    下载地址:https://github.com/jelly-liu/EOSS 一:EOSS 功能介绍 其于用户,角色,权限,资源(即菜单)的一套"简约有用"的权限管理系统,可在其基 ...

  3. Oracle分析函数ntile

    有这么一个需求.将课程的成绩分成四个等级,为学生打A.B.C.D的绩效. drop table course purge; create table course (   id number,   g ...

  4. srw阅读笔记

    第一章 p11,不要使用we来代表普遍意义上的人们,使用形式主语和被动语态

  5. python 提取主域名和子域名代码——先根据规则提取,如果有问题,则使用tldextract

    import tldextract def extract_domain(domain): suffix = {'.com','.la','.io', '.co', '.cn','.info', '. ...

  6. nyoj--514--1的个数(贪心)

     1的个数 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 给你两个数a和b,你的任务是计算出1在a和b之间出现的次数,比如说,如果a=1024,b=1032,那么a ...

  7. vim编辑器常用语法

    1)yy (功能描述:复制光标当前一行) y数字y (功能描述:复制一段(从第几行到第几行))2)p (功能描述:箭头移动到目的行粘贴)3)u (功能描述:撤销上一步)4)dd (功能描述:删除光标当 ...

  8. SQL Server查询数据库空间分配情况、数据库备份信息

    查询数据库空间分配情况: use master go create procedure dbo.proc_getdbspaceused as begin set nocount on create t ...

  9. Kafka Consumer1

    本文的代码基于kafka的0.10.1的版本. 重新设计的原因 0.9以前的consumer是通过zookeeper来进行状态管理里的. 羊群效应 任何Broker或者Consumer的增减都会触发所 ...

  10. pic中断特别说明

    在调试产品W660-MODBUS过程中发现,程序工作在偶然情况下会工作异常,经过将近一个礼拜的追踪,发现PIC中断有一下两个怪异特性: 在刚进入中断时就应该清除中断标志,如果在最后返回之前才清除标志, ...