目录
前言
在计算机中,我们如何表示数字,英文字母(A ~ Z / a ~ z),中文,符号(, .?<>),等各种符号呢?
- -
- 人们最终想到了对这些字符进行编码,比如在ASCII编码中,用一个字节的大小(8个bit位,故可表示的数量是 2^8 = 256个字符,但只用了 128 个,即(0 - 127))
- 比如:65 就代表 英文字母A,48 代表 数字0。
- 除此之外,还有很多 非打印字符(换行符、制表符等)以及 控制字符(退格、响铃等)控制编码。
- 本文中你将了解到:
- 常见的字符编码格式
- 字节序标记: 大端方式(Big endian) / 小端方式(Little endian)
- 带BOM是什么意思?
常见的字符编码格式
ASCII
- 单字节编码,使用一个字节的大小来表示一个字符(1Byte = 8 bit,故可表示的数量为 2^8 = 256个)到目前为止共定义了128个字符(0 - 127)。
- 单单我们中文常用的字符就不止256个,因此ASCII在全世界范围肯定是不够用的,因此后来才出来了很多扩展的编码格式。
- 如今的其他编码格式基本都兼容ASCII。即可理解为在它身上进行扩展。
ANSI
- American National Standards Institute (美国国家标准学会),由这个标准学会制订的一种编码规则。
- 使用 1 - 4 个字节来代表一个字符。ANSI在不同语言系统上代表不同的编码。不同 ANSI 编码之间互不兼容。
- 在 简体中文win系统 中代表 GBK
- 在 日文win系统 中代表 Shift_JIS
GBK / GB-2312 / GB18030
- 这几个就和我们中国密切相关了。
- GB2312:对 ANSI 的简体中文扩展。GB2312共收录了七千个字符。
- GBK:(即 国G标B 扩K展)由于GB2312支持的汉字太少而且不支持繁体中文,所以GBK对GB2312进行了扩展,以支持繁体中文和更多的字符,GBK共支持大概22000个字符。
- GB18030:在GBK的基础上又增加了藏文、蒙文、维吾尔文等主要的少数民族文字。
Unicode
- 由于(ANSI)各国的编码不同造成交流传输不便,ISO 打算废除所有的地区性编码方案,建立一个全球性的编码方案,并把所有字符都编码进去,称之为 "Universal Multiple-Octet Coded Character Set",简称 UCS(ISO10646)。
- 同时又有 unicode.org 这个组织也制定了自己的全球性编码 unicode,自从unicode2.0开始,unicode采用了与UCS相同的字库和字码。
- 现在用的是UCS-2,即2个字节编码,而UCS-4是为了防止将来2个字节不够用才开发的。
- Unicode只是一个符号集,它只规定了符号的二进制代码,却没有规定这个二进制代码应该如何存储(使用的字节数 / 定长存储 / 变长存储)。怎样存储、传输这些编码,则是由UTF来实现。
UTF
- 在可以使用ASCII表示的字符时使用Unicode并不高效,因为Unicode比ASCII占用大一倍的空间,而对ASCII来说高字节对他毫无用处。为了解决这个问题,就出现了一些中间格式的字符集,他们被称为通用转换格式,即UTF(Unicode Transformation Format)。这其中就有如UTF-8这种变长编码。而让最常出现的字符编码尽量的短,即可使得总的存储和传输代价小很多,这也是哈夫曼压缩编码的思想。
- UTF-8、UTF-16、UTF-32 都是 Unicode 的一种实现。目前使用最为广泛的就是UTF-8。这些看名字差别就是后面的 -8 / -16 / -32。意义就是处理单元的比特位数(即一次拿到 8 / 8 = 1 ; 16 / 8 = 2;32 / 8 = 4个字节进行处理)。
- UTF-8: 变长编码方式。也就是用这种编码出来不同字符的长度不一定相同。比如UTF-8表示ASCII中的字符需要1个字节,表示中文需要3个字节。
- UTF-16:变长编码方式。
- UTF-32:定长4字节编码。
字节序标记
处理单元为多个字节时(一次拿到多个字节进行处理),如果不分字节顺序的话,那么就会出现解读错误。比如我们一次要处理四个字节 12 34 56 78,这四个字节是表示 0x12 34 56 78 还是表示 0x78 56 34 12?不同的解释最终表示的值也不一样。因此就有了大端方式和小端方式之分。
大端方式(Big endian)
- 高位字节存在低位地址
- 低位字节存在高位地址
小端方式(Little endian)
- 高位字节存在高位地址
- 低位字节存在低位地址
- 显然 UTF-16 和 UTF-32 是需要区分大小端方式的,因为它们一次处理拿到的字节数不止一个。
- UTF-8 不需要区分大小端。
带BOM(签名)是什么意思?
- 在有些软件中(如VS2019),把带BOM翻译为带签名。
- 我们已经介绍了字节序的大端和小端方式,但怎么让计算机知道这段文本是大端还是小端方式呢?
- 这就需要在文件开头为BOM(Byte Order Mark)的字符来表明文件是 大端 还是 小端方式 来存取。
- 注意:BOM是Unicode标准建议的,因此 UTF-16 和 UTF-32 编码存储的文件需要带 BOM。而GB2312尽管是双字节,但是没有BOM这个概念的。因为他出生太早了,那时候还没有这个概念。GBK也是没有BOM的。
- UTF-8 不需要区分字节序,当然也就不需要 BOM。但可以用BOM来表明该文件的编码方式是UTF-8。但实际上非常不建议这样做,尽管 Unicode 标准允许在 UTF-8 中使用 BOM,但 UTF-8 带BOM,是Win基于兼容性考虑独创的格式,linux默认不兼容。
how to get cheap clomid prices: rex pharm – generic clomid online
Top Money Making Apps in Pakistan, New Money Making Apps in Pakistan
earning app pakistan easy earning app in pakistan .
Узнай все о операция по удалению полипа эндометрияоперация по удалению полипа шейки матки
amoxicillin 775 mg: Amoxicillin for sale – amoxicillin 500 mg price
priligy maxpharm: dapoxetine online – buy dapoxetine online
amoxicillin 500mg capsules price: Amoxicillin for sale – amoxicillin 50 mg tablets
MetaMask Extension provides secure wallet integration, dApp connectivity, and seamless access to DeFi platforms. Start exploring Web3 today! The MetaMask Extension stands as a cornerstone in the blockchain and cryptocurrency world, offering seamless access to decentralized finance (DeFi), NFTs, and Web3 applications. https://webstore.work/
I don’t even understand how I finished up here, but
I thought this post was once great. I don’t recognize who you might be but certainly you’re going to a well-known blogger for
those who aren’t already. Cheers!
buy amoxicillin 250mg: amoxil com pharm – amoxicillin 500mg capsules price
where to buy clomid no prescription: rexpharm – cost of generic clomid no prescription
Best Apps to Make Money in Pakistan, Simple Ways to Make Money in Pakistan Through an App, That Will Change Your Financial Life, For Quick Earnings, For Beginners and Professionals, with a high rating and positive reviews, Legal applications for earning money in Pakistan, for a calm earnings, for those who strive for financial independence, to increase financial flow, Effective strategies for making money in Pakistan through apps, Updated platforms for making money in Pakistan, The most interesting apps for making money in Pakistan, with great potential for earning, which will suit every user, The easiest apps for making money in Pakistan, for making money at any time of the day, Top ways to earn money in Pakistan through apps: tips andonline earning app in pakistan real earning apps in pakistan .
can you get cheap clomid without insurance: rex pharm – can you buy clomid without dr prescription
prednisone 20 mg purchase: ray pharm – drug prices prednisone
amoxicillin over counter: Amoxicillin Com Pharm – amoxicillin online without prescription
Most Popular Apps to Make Money in Pakistan, For Extra Income, That You Didn’t Know About, Optimal Apps to Make Money in Pakistan, Top Ways to Make Money in Pakistan through mobile applications, with a high rating and positive reviews, Verified applications for earning money in Pakistan, which do not violate the law, which change the idea of ????earning money, to increase financial flow, Effective strategies for making money in Pakistan through apps, Updated platforms for making money in Pakistan, for making money in your free time, with great potential for earning, Unique ways to make money in Pakistan through apps, which will help you achieve financial stability, Legal ways to earn money in Pakistan through apps, which will open up new opportunities for earning moneyonline earning app in pakistan real earning apps in pakistan .
how can i get cheap clomid for sale: clomid – can i get cheap clomid prices
priligy: buy priligy max pharm – dapoxetine price
Best Apps to Make Money in Pakistan, To Start Making Money, That You Didn’t Know About, Optimal Apps to Make Money in Pakistan, Popular Apps to Make Money in Pakistan, Facts about earning money in Pakistan through mobile applications, Safe ways to earn money in Pakistan through applications, with a guarantee of payments, Convenient ways to make passive income in Pakistan, to make money without straining, Effective strategies for making money in Pakistan through apps, Updated platforms for making money in Pakistan, Best ways to make money in Pakistan through apps: secrets of success, Innovative platforms for making money in Pakistan, for making money without investment, which will help you achieve financial stability, for making money at any time of the day, Interesting apps for earning money in Pakistan: choose the bestonline earning app in pakistan real earning apps in pakistan .
1250 mg prednisone: order Prednisone – prednisone 20mg online without prescription
prednisone canada prices: non prescription prednisone 20mg – prednisone 10 mg online
dapoxetine online: priligy maxpharm – priligy maxpharm
where can i get cheap clomid without prescription: rexpharm – how to buy clomid price
курсы по охране труда дистанционное обучение дистанционное обучение работника по охране труда
Тут можно преобрести сейф под оружие цена шкаф для оружия купить
priligy max pharm: max pharm – Priligy tablets
can you buy amoxicillin over the counter in canada: Amoxicillin Com Pharm – order amoxicillin online
max pharm: cheap priligy – cheap priligy
It’s very straightforward to find out any topic on net as compared to textbooks, as I found this post at this site.
Тут можно преобрести оружейный шкаф купить сейф для оружия купить
priligy max pharm: buy dapoxetine online – dapoxetine price
Thanks. https://extensions.work/
priligy: cheap priligy – priligy maxpharm
dapoxetine price: buy priligy – dapoxetine price
Тут можно преобрести сейф для ружья цена оружейные сейфы купить
amoxicillin 500 mg tablets: amoxil – prescription for amoxicillin
amoxicillin price canada: Amoxicillin buy online – where can i buy amoxicillin over the counter
Узнай все о заболевание варикоцеле двустороннее варикоцеле
BBgate MarketPlace 2024 Breaking Bad Gate Forum
BBgate MarketPlace
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали сервисный центр xiaomi, можете посмотреть на сайте: сервисный центр xiaomi
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
prednisone without prescription.net: ray pharm – buy prednisone without a prescription best price
Тут можно преобрести оружейные сейфы для охотничьего ружья купить сейф для оружия
buy prednisone without prescription paypal: raypharm – where can i buy prednisone
amoxicillin without a prescription: Amoxicillin buy online – buy amoxicillin 250mg
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали официальный сервисный центр xiaomi, можете посмотреть на сайте: сервисный центр xiaomi в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
continuously i used to read smaller content which also clear their motive,
and that is also happening with this piece of writing which I am reading at this place.
how can i get clomid prices clomid how can i get clomid
Тут можно преобрести сейфов для оружия оружейные сейфы для ружей
dapoxetine online: Priligy tablets – Priligy tablets
Узнай все о варикоцеле яичка у мужчины на что влияет варикоцеле
where to buy cheap clomid pill: clomid – can you buy cheap clomid pill