/usr/share/doc/python-pycurl-doc/html/unicode.html is in python-pycurl-doc 7.19.5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>String And Unicode Handling — PycURL 7.19.5 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '7.19.5',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="top" title="PycURL 7.19.5 documentation" href="index.html" />
<link rel="next" title="File Handling" href="files.html" />
<link rel="prev" title="curl Module Functionality" href="curl.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="files.html" title="File Handling"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="curl.html" title="curl Module Functionality"
accesskey="P">previous</a> |</li>
<li><a href="index.html">PycURL 7.19.5 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="string-and-unicode-handling">
<span id="unicode"></span><h1>String And Unicode Handling<a class="headerlink" href="#string-and-unicode-handling" title="Permalink to this headline">¶</a></h1>
<p>Generally speaking, libcurl does not perform data encoding or decoding.
In particular, libcurl is not Unicode-aware, but operates on byte streams.
libcurl leaves it up to the application - PycURL library or an application
using PycURL in this case - to encode and decode Unicode data into byte streams.</p>
<p>PycURL, being a thin wrapper around libcurl, generally does not perform
this encoding and decoding either, leaving it up to the application.
Specifically:</p>
<ul class="simple">
<li>Data that PycURL passes to an application, such as via callback functions,
is normally byte strings. The application must decode them to obtain text
(Unicode) data.</li>
<li>Data that an application passes to PycURL, such as via <tt class="docutils literal"><span class="pre">setopt</span></tt> calls,
must normally be byte strings appropriately encoded. For convenience and
compatibility with existing code, PycURL will accept Unicode strings that
contain ASCII code points only <a class="footnote-reference" href="#ascii" id="id1">[1]</a>, and transparently encode these to
byte strings.</li>
</ul>
<div class="section" id="setting-options-python-2-x">
<h2>Setting Options - Python 2.x<a class="headerlink" href="#setting-options-python-2-x" title="Permalink to this headline">¶</a></h2>
<p>Under Python 2, the <tt class="docutils literal"><span class="pre">str</span></tt> type can hold arbitrary encoded byte strings.
PycURL will pass whatever byte strings it is given verbatim to libcurl.
The following code will work:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">pycurl</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">pycurl</span><span class="o">.</span><span class="n">Curl</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">'Foo</span><span class="se">\xa9</span><span class="s">'</span><span class="p">)</span>
<span class="go"># ok</span>
</pre></div>
</div>
<p>Unicode strings can be used but must contain ASCII code points only:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">u'Foo'</span><span class="p">)</span>
<span class="go"># ok</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">u'Foo</span><span class="se">\xa9</span><span class="s">'</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">UnicodeEncodeError</span>: <span class="n">'ascii' codec can't encode character u'\xa9' in position 3: ordinal not in range(128)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">u'Foo</span><span class="se">\xa9</span><span class="s">'</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">'iso-8859-1'</span><span class="p">))</span>
<span class="go"># ok</span>
</pre></div>
</div>
</div>
<div class="section" id="setting-options-python-3-x">
<h2>Setting Options - Python 3.x<a class="headerlink" href="#setting-options-python-3-x" title="Permalink to this headline">¶</a></h2>
<p>Under Python 3, the <tt class="docutils literal"><span class="pre">bytes</span></tt> type holds arbitrary encoded byte strings.
PycURL will accept <tt class="docutils literal"><span class="pre">bytes</span></tt> values for all options where libcurl specifies
a “string” argument:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">pycurl</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">pycurl</span><span class="o">.</span><span class="n">Curl</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="n">b</span><span class="s">'Foo</span><span class="se">\xa9</span><span class="s">'</span><span class="p">)</span>
<span class="go"># ok</span>
</pre></div>
</div>
<p>The <tt class="docutils literal"><span class="pre">str</span></tt> type holds Unicode data. PycURL will accept <tt class="docutils literal"><span class="pre">str</span></tt> values
containing ASCII code points only:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">'Foo'</span><span class="p">)</span>
<span class="go"># ok</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">'Foo</span><span class="se">\xa9</span><span class="s">'</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">UnicodeEncodeError</span>: <span class="n">'ascii' codec can't encode character '\xa9' in position 3: ordinal not in range(128)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">'Foo</span><span class="se">\xa9</span><span class="s">'</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">'iso-8859-1'</span><span class="p">))</span>
<span class="go"># ok</span>
</pre></div>
</div>
</div>
<div class="section" id="writing-to-files">
<h2>Writing To Files<a class="headerlink" href="#writing-to-files" title="Permalink to this headline">¶</a></h2>
<p>PycURL will return all data read from the network as byte strings. On Python 2,
this means the write callbacks will receive <tt class="docutils literal"><span class="pre">str</span></tt> objects, and
on Python 3, write callbacks will receive <tt class="docutils literal"><span class="pre">bytes</span></tt> objects.</p>
<p>Under Python 2, when using e.g. <tt class="docutils literal"><span class="pre">WRITEDATA</span></tt> or <tt class="docutils literal"><span class="pre">WRITEFUNCTION</span></tt> options,
files being written to <em>should</em> be opened in binary mode. Writing to files
opened in text mode will not raise exceptions but may corrupt data.</p>
<p>Under Python 3, PycURL passes strings and binary data to the application
using <tt class="docutils literal"><span class="pre">bytes</span></tt> instances. When writing to files, the files must be opened
in binary mode for the writes to work:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pycurl</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">pycurl</span><span class="o">.</span><span class="n">Curl</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">URL</span><span class="p">,</span><span class="s">'http://pycurl.sourceforge.net'</span><span class="p">)</span>
<span class="c"># File opened in binary mode.</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s">'/dev/null'</span><span class="p">,</span><span class="s">'wb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">WRITEDATA</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
<span class="c"># Same result if using WRITEFUNCTION instead:</span>
<span class="c">#c.setopt(c.WRITEFUNCTION, f.write)</span>
<span class="n">c</span><span class="o">.</span><span class="n">perform</span><span class="p">()</span>
<span class="c"># ok</span>
</pre></div>
</div>
<p>If a file is opened in text mode (<tt class="docutils literal"><span class="pre">w</span></tt> instead of <tt class="docutils literal"><span class="pre">wb</span></tt> mode), an error
similar to the following will result:</p>
<div class="highlight-python"><div class="highlight"><pre>TypeError: must be str, not bytes
Traceback (most recent call last):
File "/tmp/test.py", line 8, in <module>
c.perform()
pycurl.error: (23, 'Failed writing body (0 != 168)')
</pre></div>
</div>
<p>The TypeError is actually an exception raised by Python which will be printed,
but not propagated, by PycURL. PycURL will raise a <tt class="docutils literal"><span class="pre">pycurl.error</span></tt> to
signify operation failure.</p>
</div>
<div class="section" id="writing-to-stringio-bytesio">
<h2>Writing To StringIO/BytesIO<a class="headerlink" href="#writing-to-stringio-bytesio" title="Permalink to this headline">¶</a></h2>
<p>Under Python 2, response can be saved in memory by using a <tt class="docutils literal"><span class="pre">StringIO</span></tt>
object:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pycurl</span>
<span class="kn">from</span> <span class="nn">StringIO</span> <span class="kn">import</span> <span class="n">StringIO</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">pycurl</span><span class="o">.</span><span class="n">Curl</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">URL</span><span class="p">,</span><span class="s">'http://pycurl.sourceforge.net'</span><span class="p">)</span>
<span class="nb">buffer</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">WRITEDATA</span><span class="p">,</span> <span class="nb">buffer</span><span class="p">)</span>
<span class="c"># Same result if using WRITEFUNCTION instead:</span>
<span class="c">#c.setopt(c.WRITEFUNCTION, buffer.write)</span>
<span class="n">c</span><span class="o">.</span><span class="n">perform</span><span class="p">()</span>
<span class="c"># ok</span>
</pre></div>
</div>
<p>Under Python 3, as PycURL invokes the write callback with <tt class="docutils literal"><span class="pre">bytes</span></tt> argument,
the response must be written to a <tt class="docutils literal"><span class="pre">BytesIO</span></tt> object:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pycurl</span>
<span class="kn">from</span> <span class="nn">io</span> <span class="kn">import</span> <span class="n">BytesIO</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">pycurl</span><span class="o">.</span><span class="n">Curl</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">URL</span><span class="p">,</span><span class="s">'http://pycurl.sourceforge.net'</span><span class="p">)</span>
<span class="nb">buffer</span> <span class="o">=</span> <span class="n">BytesIO</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">WRITEDATA</span><span class="p">,</span> <span class="nb">buffer</span><span class="p">)</span>
<span class="c"># Same result if using WRITEFUNCTION instead:</span>
<span class="c">#c.setopt(c.WRITEFUNCTION, buffer.write)</span>
<span class="n">c</span><span class="o">.</span><span class="n">perform</span><span class="p">()</span>
<span class="c"># ok</span>
</pre></div>
</div>
<p>Attempting to use a <tt class="docutils literal"><span class="pre">StringIO</span></tt> object will produce an error:</p>
<div class="highlight-python"><div class="highlight"><pre>import pycurl
from io import StringIO
c = pycurl.Curl()
c.setopt(c.URL,'http://pycurl.sourceforge.net')
buffer = StringIO()
c.setopt(c.WRITEDATA, buffer)
c.perform()
TypeError: string argument expected, got 'bytes'
Traceback (most recent call last):
File "/tmp/test.py", line 9, in <module>
c.perform()
pycurl.error: (23, 'Failed writing body (0 != 168)')
</pre></div>
</div>
<p>The following idiom can be used for code that needs to be compatible with both
Python 2 and Python 3:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pycurl</span>
<span class="k">try</span><span class="p">:</span>
<span class="c"># Python 3</span>
<span class="kn">from</span> <span class="nn">io</span> <span class="kn">import</span> <span class="n">BytesIO</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
<span class="c"># Python 2</span>
<span class="kn">from</span> <span class="nn">StringIO</span> <span class="kn">import</span> <span class="n">StringIO</span> <span class="k">as</span> <span class="n">BytesIO</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">pycurl</span><span class="o">.</span><span class="n">Curl</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">URL</span><span class="p">,</span><span class="s">'http://pycurl.sourceforge.net'</span><span class="p">)</span>
<span class="nb">buffer</span> <span class="o">=</span> <span class="n">BytesIO</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">WRITEDATA</span><span class="p">,</span> <span class="nb">buffer</span><span class="p">)</span>
<span class="n">c</span><span class="o">.</span><span class="n">perform</span><span class="p">()</span>
<span class="c"># ok</span>
<span class="c"># Decode the response body:</span>
<span class="n">string_body</span> <span class="o">=</span> <span class="nb">buffer</span><span class="o">.</span><span class="n">getvalue</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s">'utf-8'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="header-functions">
<h2>Header Functions<a class="headerlink" href="#header-functions" title="Permalink to this headline">¶</a></h2>
<p>Although headers are often ASCII text, they are still returned as
<tt class="docutils literal"><span class="pre">bytes</span></tt> instances on Python 3 and thus require appropriate decoding.
HTTP headers are encoded in ISO/IEC 8859-1 according to the standards.</p>
<p>When using <tt class="docutils literal"><span class="pre">WRITEHEADER</span></tt> option to write headers to files, the files
should be opened in binary mode in Python 2 and must be opened in binary
mode in Python 3, same as with <tt class="docutils literal"><span class="pre">WRITEDATA</span></tt>.</p>
</div>
<div class="section" id="read-functions">
<h2>Read Functions<a class="headerlink" href="#read-functions" title="Permalink to this headline">¶</a></h2>
<p>Read functions are expected to provide data in the same fashion as
string options expect it:</p>
<ul class="simple">
<li>On Python 2, the data can be given as <tt class="docutils literal"><span class="pre">str</span></tt> instances, appropriately
encoded.</li>
<li>On Python 2, the data can be given as <tt class="docutils literal"><span class="pre">unicode</span></tt> instances containing
ASCII code points only.</li>
<li>On Python 3, the data can be given as <tt class="docutils literal"><span class="pre">bytes</span></tt> instances.</li>
<li>On Python 3. the data can be given as <tt class="docutils literal"><span class="pre">str</span></tt> instances containing
ASCII code points only.</li>
</ul>
<p>Caution: when using CURLOPT_READFUNCTION in tandem with CURLOPT_POSTFIELDSIZE,
as would be done for HTTP for example, take care to pass the length of
<em>encoded</em> data to CURLOPT_POSTFIELDSIZE if you are performing the encoding.
If you pass the number of Unicode characters rather than
encoded bytes to libcurl, the server will receive wrong Content-Length.
Alternatively you can return Unicode strings from a CURLOPT_READFUNCTION
function, if your data contains only ASCII code points,
and let PycURL encode them for you.</p>
</div>
<div class="section" id="how-pycurl-handles-unicode-strings">
<h2>How PycURL Handles Unicode Strings<a class="headerlink" href="#how-pycurl-handles-unicode-strings" title="Permalink to this headline">¶</a></h2>
<p>If PycURL is given a Unicode string which contains non-ASCII code points,
and as such cannot be encoded to ASCII,PycURL will return an error to libcurl,
and libcurl in turn will fail the request with an error like
“read function error/data error”. PycURL will then raise <tt class="docutils literal"><span class="pre">pycurl.error</span></tt>
with this latter message. The encoding exception that was the
underlying cause of the problem is stored as <tt class="docutils literal"><span class="pre">sys.last_value</span></tt>.</p>
</div>
<div class="section" id="figuring-out-correct-encoding">
<h2>Figuring Out Correct Encoding<a class="headerlink" href="#figuring-out-correct-encoding" title="Permalink to this headline">¶</a></h2>
<p>What encoding should be used when is a complicated question. For example,
when working with HTTP:</p>
<ul class="simple">
<li>URLs and POSTFIELDS data must be URL-encoded. A URL-encoded string has
only ASCII code points.</li>
<li>Headers must be ISO/IEC 8859-1 encoded.</li>
<li>Encoding for bodies is specified in Content-Type and Content-Encoding headers.</li>
</ul>
</div>
<div class="section" id="legacy-pycurl-versions">
<h2>Legacy PycURL Versions<a class="headerlink" href="#legacy-pycurl-versions" title="Permalink to this headline">¶</a></h2>
<p>The Unicode handling documented here was implemented in PycURL 7.19.3
along with Python 3 support. Prior to PycURL 7.19.3 Unicode data was not
accepted at all:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">pycurl</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">pycurl</span><span class="o">.</span><span class="n">Curl</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">setopt</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">USERAGENT</span><span class="p">,</span> <span class="s">u'Foo</span><span class="se">\xa9</span><span class="s">'</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">TypeError</span>: <span class="n">invalid arguments to setopt</span>
</pre></div>
</div>
<p>Some GNU/Linux distributions provided Python 3 packages of PycURL prior to
PycURL 7.19.3. These packages included unofficial patches
(<a class="footnote-reference" href="#patch1" id="id2">[2]</a>, <a class="footnote-reference" href="#patch2" id="id3">[3]</a>) which did not handle Unicode correctly, and did not behave
as described in this document. Such unofficial versions of PycURL should
be avoided.</p>
<p class="rubric">Footnotes</p>
<table class="docutils footnote" frame="void" id="ascii" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>Only ASCII is accepted; ISO-8859-1/Latin 1, for example, will be
rejected.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="patch1" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td><a class="reference external" href="http://sourceforge.net/p/pycurl/patches/5/">http://sourceforge.net/p/pycurl/patches/5/</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="patch2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id3">[3]</a></td><td><a class="reference external" href="http://sourceforge.net/p/pycurl/patches/12/">http://sourceforge.net/p/pycurl/patches/12/</a></td></tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">String And Unicode Handling</a><ul>
<li><a class="reference internal" href="#setting-options-python-2-x">Setting Options - Python 2.x</a></li>
<li><a class="reference internal" href="#setting-options-python-3-x">Setting Options - Python 3.x</a></li>
<li><a class="reference internal" href="#writing-to-files">Writing To Files</a></li>
<li><a class="reference internal" href="#writing-to-stringio-bytesio">Writing To StringIO/BytesIO</a></li>
<li><a class="reference internal" href="#header-functions">Header Functions</a></li>
<li><a class="reference internal" href="#read-functions">Read Functions</a></li>
<li><a class="reference internal" href="#how-pycurl-handles-unicode-strings">How PycURL Handles Unicode Strings</a></li>
<li><a class="reference internal" href="#figuring-out-correct-encoding">Figuring Out Correct Encoding</a></li>
<li><a class="reference internal" href="#legacy-pycurl-versions">Legacy PycURL Versions</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="curl.html"
title="previous chapter">curl Module Functionality</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="files.html"
title="next chapter">File Handling</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/unicode.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="files.html" title="File Handling"
>next</a> |</li>
<li class="right" >
<a href="curl.html" title="curl Module Functionality"
>previous</a> |</li>
<li><a href="index.html">PycURL 7.19.5 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2001-2014 Kjetil Jacobsen, Markus F.X.J. Oberhumer, Oleg Pudeyev.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
</div>
</body>
</html>
|