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

Skip to content

Commit 8758446

Browse files
[po] auto sync
1 parent e5924b9 commit 8758446

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

howto/unicode.po

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,26 +681,31 @@ msgid ""
681681
"notes.curiousefficiency.org/en/latest/python3/text_file_processing.html>`_, "
682682
"by Nick Coghlan."
683683
msgstr ""
684+
"`用 Python 3 处理文本文件 <http://python-"
685+
"notes.curiousefficiency.org/en/latest/python3/text_file_processing.html>`_ "
686+
",作者 Nick Coghlan。"
684687

685688
#: ../../howto/unicode.rst:520
686689
msgid ""
687690
"`Pragmatic Unicode <https://nedbatchelder.com/text/unipain.html>`_, a PyCon "
688691
"2012 presentation by Ned Batchelder."
689692
msgstr ""
693+
"`实用的 Unicode <https://nedbatchelder.com/text/unipain.html>`_,Ned Batchelder "
694+
"在 PyCon 2012 上的演示。"
690695

691696
#: ../../howto/unicode.rst:522
692697
msgid ""
693698
"The :class:`str` type is described in the Python library reference at "
694699
":ref:`textseq`."
695-
msgstr ""
700+
msgstr ":class:`str` 类型在 Python 库参考文档 :ref:`textseq` 中有介绍。 "
696701

697702
#: ../../howto/unicode.rst:525
698703
msgid "The documentation for the :mod:`unicodedata` module."
699-
msgstr ""
704+
msgstr ":mod:`unicodedata` 模块的文档"
700705

701706
#: ../../howto/unicode.rst:527
702707
msgid "The documentation for the :mod:`codecs` module."
703-
msgstr ""
708+
msgstr ":mod:`codecs` 模块的文档"
704709

705710
#: ../../howto/unicode.rst:529
706711
msgid ""
@@ -710,17 +715,23 @@ msgid ""
710715
"Python 2's Unicode features (where the Unicode string type is called "
711716
"``unicode`` and literals start with ``u``)."
712717
msgstr ""
718+
"Marc-André Lemburg 在 EuroPython 2002 上做了一个题为“Python 和 Unicode”(PDF "
719+
"幻灯片)<https://downloads.egenix.com/python/Unicode-EPC2002-Talk.pdf>`_ "
720+
"的演示文稿。该幻灯片很好地概括了 Python 2 的 Unicode 功能设计(其中 Unicode 字符串类型称为 ``unicode``,文字以 "
721+
"``u`` 开头)。"
713722

714723
#: ../../howto/unicode.rst:537
715724
msgid "Reading and Writing Unicode Data"
716-
msgstr ""
725+
msgstr "Unicode 数据的读写"
717726

718727
#: ../../howto/unicode.rst:539
719728
msgid ""
720729
"Once you've written some code that works with Unicode data, the next problem"
721730
" is input/output. How do you get Unicode strings into your program, and how"
722731
" do you convert Unicode into a form suitable for storage or transmission?"
723732
msgstr ""
733+
"既然处理 Unicode 数据的代码写好了,下一个问题就是输入/输出了。如何将 Unicode 字符串读入程序,如何将 Unicode "
734+
"转换为适于存储或传输的形式呢?"
724735

725736
#: ../../howto/unicode.rst:543
726737
msgid ""
@@ -730,6 +741,8 @@ msgid ""
730741
"Unicode data, for example. Many relational databases also support Unicode-"
731742
"valued columns and can return Unicode values from an SQL query."
732743
msgstr ""
744+
"根据输入源和输出目标的不同,或许什么都不用干;请检查一下应用程序用到的库是否原生支持 Unicode。例如,XML 解析器往往会返回 Unicode "
745+
"数据。许多关系数据库的字段也支持 Unicode 值,并且 SQL 查询也能返回 Unicode 值。"
733746

734747
#: ../../howto/unicode.rst:549
735748
msgid ""
@@ -739,6 +752,8 @@ msgid ""
739752
"bytes with ``bytes.decode(encoding)``. However, the manual approach is not "
740753
"recommended."
741754
msgstr ""
755+
"在写入磁盘或通过套接字发送之前,Unicode 数据通常要转换为特定的编码。可以自己完成所有工作:打开一个文件,从中读取一个 8 位字节对象,然后用 "
756+
"``bytes.decode(encoding)`` 对字节串进行转换。但是,不推荐采用这种全人工的方案。 "
742757

743758
#: ../../howto/unicode.rst:554
744759
msgid ""
@@ -753,6 +768,10 @@ msgid ""
753768
"at least a moment you'd need to have both the encoded string and its Unicode"
754769
" version in memory.)"
755770
msgstr ""
771+
"编码的多字节特性就是一个难题; 一个 Unicode 字符可以用几个字节表示。 如果要以任意大小的块(例如 1024 或 4096 "
772+
"字节)读取文件,那么在块的末尾可能只读到某个 Unicode 字符的部分字节,这就需要编写错误处理代码。 "
773+
"有一种解决方案是将整个文件读入内存,然后进行解码,但这样就没法处理很大的文件了;若要读取 2 GB 的文件,就需要 2 GB 的 "
774+
"RAM。(其实需要的内存会更多些,因为至少有一段时间需要在内存中同时存放已编码字符串及其 Unicode 版本。)"
756775

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

769792
#: ../../howto/unicode.rst:573
770793
msgid "Reading Unicode from a file is therefore simple::"
771-
msgstr ""
794+
msgstr "因此从文件读取 Unicode 就比较简单了:"
772795

773796
#: ../../howto/unicode.rst:579
774797
msgid ""
775798
"It's also possible to open files in update mode, allowing both reading and "
776799
"writing::"
777-
msgstr ""
800+
msgstr "也可以在更新模式下打开文件,以便同时读取和写入:"
778801

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

792819
#: ../../howto/unicode.rst:596
793820
msgid ""

0 commit comments

Comments
 (0)