@@ -1273,6 +1273,10 @@ msgid ""
12731273"which are collectivity referred to as :term:`text encodings <text "
12741274"encoding>`."
12751275msgstr ""
1276+ "字符串在系统内部存储为 ``0x0``--``0x10FFFF`` 范围内的码位序列。 (请参阅 :pep:`393` 了解有关实现的详情。) "
1277+ "一旦字符串对象要在 CPU 和内存以外使用,字节的大小端顺序和字节数组的存储方式就成为一个关键问题。 "
1278+ "如同使用其他编解码器一样,将字符串序列化为字节序列被称为 *编码*,而从字节序列重建字符串被称为 *解码*。 "
1279+ "存在许多不同的文本序列化编解码器,它们被统称为 :term:`文本编码 <text encoding>`。"
12761280
12771281#: ../../library/codecs.rst:878
12781282msgid ""
@@ -1284,6 +1288,11 @@ msgid ""
12841288"``UnicodeEncodeError: 'latin-1' codec can't encode character '\\ u1234' in "
12851289"position 3: ordinal not in range(256)``."
12861290msgstr ""
1291+ "最简单的文本编码格式 (称为 ``'latin-1'`` 或 ``'iso-8859-1'``) 将码位 0--255 映射为字节值 "
1292+ "``0x0``--``0xff``,这意味着包含 ``U+00FF`` 以上码位的字符串对象无法使用此编解码器进行编码。 这样做将引发 "
1293+ ":exc:`UnicodeEncodeError`,其形式类似下面这样(不过详细的错误信息可能会有所不同): ``UnicodeEncodeError:"
1294+ " 'latin-1' codec can't encode character '\\ u1234' in position 3: ordinal not"
1295+ " in range(256)``。"
12871296
12881297#: ../../library/codecs.rst:886
12891298msgid ""
@@ -1294,6 +1303,9 @@ msgid ""
12941303"used primarily on Windows). There's a string constant with 256 characters "
12951304"that shows you which character is mapped to which byte value."
12961305msgstr ""
1306+ "还有另外一组编码格式(所谓的字符映射编码)会选择全部 Unicode 码位的不同子集并设定如何将这些码位映射为字节值 "
1307+ "``0x0``--``0xff``。 要查看这是如何实现的,只需简单地打开相应源码例如 :file:`encodings/cp1252.py` "
1308+ "(这是一个主要在 Windows 上使用的编码格式)。 其中会有一个包含 256 个字符的字符串常量,指明每个字符所映射的字节值。"
12971309
12981310#: ../../library/codecs.rst:893
12991311msgid ""
0 commit comments