Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 292c2b0

Browse files
[po] auto sync
1 parent e13a084 commit 292c2b0

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

howto/unicode.po

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ msgid ""
777777
"at least a moment you'd need to have both the encoded string and its Unicode"
778778
" version in memory.)"
779779
msgstr ""
780+
"编码的多字节特性就是一个难题; 一个 Unicode 字符可以用几个字节表示。 如果要以任意大小的块(例如 1024 或 4096 "
781+
"字节)读取文件,那么在块的末尾可能只读到某个 Unicode 字符的部分字节,这就需要编写错误处理代码。 "
782+
"有一种解决方案是将整个文件读入内存,然后进行解码,但这样就没法处理很大的文件了;若要读取 2 GB 的文件,就需要 2 GB 的 "
783+
"RAM。(其实需要的内存会更多些,因为至少有一段时间需要在内存中同时存放已编码字符串及其 Unicode 版本。)"
780784

781785
#: ../../howto/unicode.rst:565
782786
msgid ""
@@ -789,16 +793,20 @@ msgid ""
789793
"*encoding* and *errors* parameters which are interpreted just like those in "
790794
":meth:`str.encode` and :meth:`bytes.decode`."
791795
msgstr ""
796+
"解决方案是利用底层解码接口去捕获编码序列不完整的情况。这部分代码已经是现成的:内置函数 :func:`open` "
797+
"可以返回一个文件类的对象,该对象认为文件的内容采用指定的编码,:meth:`~io.TextIOBase.read` 和 "
798+
":meth:`~io.TextIOBase.write` 等方法接受 Unicode 参数。只要用 :func:`open` 的 *encoding* "
799+
"和 *errors* 参数即可,参数释义同 :meth:`str.encode` 和 :meth:`bytes.decode` 。 "
792800

793801
#: ../../howto/unicode.rst:574
794802
msgid "Reading Unicode from a file is therefore simple::"
795-
msgstr ""
803+
msgstr "因此从文件读取 Unicode 就比较简单了:"
796804

797805
#: ../../howto/unicode.rst:580
798806
msgid ""
799807
"It's also possible to open files in update mode, allowing both reading and "
800808
"writing::"
801-
msgstr ""
809+
msgstr "也可以在更新模式下打开文件,以便同时读取和写入:"
802810

803811
#: ../../howto/unicode.rst:588
804812
msgid ""
@@ -812,6 +820,10 @@ msgid ""
812820
"endian encodings, that specify one particular byte ordering and don't skip "
813821
"the BOM."
814822
msgstr ""
823+
"Unicode 字符 ``U+FEFF`` 用作字节顺序标记(BOM),通常作为文件的第一个字符写入,以帮助自动检测文件的字节顺序。某些编码(例如 "
824+
"UTF-16)期望在文件开头出现 BOM;当采用这种编码时,BOM 将自动作为第一个字符写入,并在读取文件时会静默删除。这些编码有多种变体,例如用于 "
825+
"little-endian 和 big-endian 编码的 “utf-16-le” 和 “utf-16-be”,会指定一种特定的字节顺序并且不会忽略 "
826+
"BOM。"
815827

816828
#: ../../howto/unicode.rst:597
817829
msgid ""

0 commit comments

Comments
 (0)