Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24795

Re: helping with unicode

Date 2012-07-02 20:14 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
Subject Re: helping with unicode
References <56e3cafd-ec4f-4ae4-ad6c-685f2d991403@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1723.1341278107.4697.python-list@python.org> (permalink)

Show all headers | View raw


On 7/2/2012 7:49 PM, self.python wrote:
> ----------------------------------------------------------------
> Traceback (most recent call last):
>   File "C:wrong.py", line 8, in <module>
>     print rf.read().decode('utf-8')
> UnicodeEncodeError: 'cp949' codec can't encode character u'u1368' in position 5
> 5122: illegal multibyte sequence
> ---------------------------------------------------------------------
> 
> cp949 is the basic codec of sys.stdout and cmd.exe  
> but I have no idea why it doesn't works.
> printing without decode('utf-8') works fine on IDLE but on cmd, it print broken characters(Ascii portion is still fine, problem is only about the Korean)
Your terminal can't display those characters. You could try using other
code pages with chcp (a CLI utility that is part of Windows). IDLE is a
GUI, so it does not have to work with code pages.

Python 3.3 supports cp65001 (which is the equivalent of UTF-8 for
Windows terminals), but unfortunately, previous versions do not.
-- 
CPython 3.3.0a4 | Windows NT 6.1.7601.17803

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

helping with unicode "self.python" <howmuchistoday@gmail.com> - 2012-07-02 17:49 -0700
  Re: helping with unicode Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-02 20:14 -0500
  Re: helping with unicode MRAB <python@mrabarnett.plus.com> - 2012-07-03 02:21 +0100
  Re: helping with unicode Terry Reedy <tjreedy@udel.edu> - 2012-07-02 21:39 -0400
  Re: helping with unicode Terry Reedy <tjreedy@udel.edu> - 2012-07-02 21:39 -0400

csiph-web