什么是“代理对”?在Java? [英] What is a "surrogate pair" in Java?

查看:455
本文介绍了什么是“代理对”?在Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 StringBuffer 的文档,特别是 reverse()方法。该文档提到了关于代理对的一些内容。在这种情况下,什么是代理对?什么是代理人?

I was reading the documentation for StringBuffer, in particular the reverse() method. That documentation mentions something about surrogate pairs. What is a surrogate pair in this context? And what are low and high surrogates?

推荐答案

术语代理对是指使用UTF-16编码中的高代码点编码Unicode字符的方法scheme。

The term "surrogate pair" refers to a means of encoding Unicode characters with high code-points in the UTF-16 encoding scheme.

在Unicode字符编码中,字符被映射到0x0和0x10FFFF之间的值。

In the Unicode character encoding, characters are mapped to values between 0x0 and 0x10FFFF.

在内部, Java使用UTF-16编码方案来存储Unicode文本的字符串。在UTF-16中,使用16位(双字节)代码单元。由于16位只能包含从0x0到0xFFFF的字符范围,因此使用一些额外的复杂度来存储高于此范围(0x10000到0x10FFFF)的值。这是使用称为代理的代码单元对完成的。

Internally, Java uses the UTF-16 encoding scheme to store strings of Unicode text. In UTF-16, 16-bit (two-byte) code units are used. Since 16 bits can only contain the range of characters from 0x0 to 0xFFFF, some additional complexity is used to store values above this range (0x10000 to 0x10FFFF). This is done using pairs of code units known as surrogates.

代理代码单元分为两个范围,称为高代理和低代理,具体取决于是否它们被允许在两个代码单元序列的开头或结尾。

The surrogate code units are in two ranges known as "high surrogates" and "low surrogates", depending on whether they are allowed at the start or end of the two-code-unit sequence.

这篇关于什么是“代理对”?在Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆