Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem probably is that the output encoding of the environment is set to cp437 and the unicode character cannot be converted to that encoding when doing <code>print(line)</code> that probably translates to the <code>self.old_out.write(value)</code>.</p> <p>Try to replace the <code>print()</code> inside the loop by writing to the file, like:</p> <pre><code>with open('myoutput.txt', 'w', encoding='utf-8') as f: for line in cur: f.write(line) </code></pre> <p>Well, but the cursor does not return a string line. It return a row (I guess tuple) of elements. Because of that you probably have to do something like that:</p> <pre><code>with open('myoutput.txt', 'w', encoding='utf-8') as f: for row in cur: f.write(repr(row)) </code></pre> <p>This may be enough for a diagnostic purpose. If you need some nicer string, you have to format it in some specific way.</p> <p>Also, you wrote:</p> <pre><code> charset="utf8", use_unicode=True) </code></pre> <p>If the <code>charset</code> is used, then <code>use_unicode=True</code> can be left out (it is implied by using the <code>charset</code>. If I recall correctly, the <code>charset='utf8'</code> is not any recognized encoding for Python. You have to use <code>charset='utf-8'</code> -- i.e. with dash or underscore between <code>utf</code> and <code>8</code>. <strong>Correction:</strong> The <code>utf8</code> probably works as it is one of the aliases. </p> <p><strong>UPDATE</strong> based on comments...</p> <p>As the output to a file seems to be OK, the problem is related to the capabilities of the window used for the output of the <code>print</code> command. As the <code>cmd</code> knows only cp437, you have to use or another window (like a Unicode capable window of some GUI), or you have to tell the <code>cmd</code> to use another encoding. See the <a href="https://stackoverflow.com/q/388490/1346705">experience of others</a>. Basically, you have to tell the console:</p> <pre><code>chcp 65001 </code></pre> <p>to change accepted output encoding to UTF-8, or you can use another (non-Unicode) encoding that supports the wanted characters. Also, the console font should be capable to display the characters (i.e. to contain the glyphs, the images of the characters).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload