Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41261
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Thomas Heller <theller@ctypes.org> |
| Newsgroups | comp.lang.python |
| Subject | Unicode |
| Date | Fri, 15 Mar 2013 11:46:36 +0100 |
| Lines | 34 |
| Message-ID | <aqgcesFio46U1@mid.individual.net> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net CelUBGmgOXJ/RjHnuHX8eACm/inKUU+vWezGaU1Hqrb3tQZAI= |
| Cancel-Lock | sha1:/Uhie3gUcYBQ2Ys2B8WXiP3Ig6I= |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 |
| Xref | csiph.com comp.lang.python:41261 |
Show key headers only | View raw
I thought I understand unicode (somewhat, at least), but this seems
not to be the case.
I expected the following code to print 'µm' two times to the console:
<code>
# -*- coding: cp850 -*-
a = u"µm"
b = u"\u03bcm"
print(a)
print(b)
</code>
But what I get is this:
<output>
µm
Traceback (most recent call last):
File "x.py", line 7, in <module>
print(b)
File "C:\Python33-64\lib\encodings\cp850.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u03bc' in
position 0: character maps to <undefined>
</output>
Using (german) windows, command prompt, codepage 850.
The same happens with Python 2.7. What am I doing wrong?
Thanks,
Thomas
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Unicode Thomas Heller <theller@ctypes.org> - 2013-03-15 11:46 +0100
Re: Unicode Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-15 10:58 +0000
Re: Unicode Thomas Heller <theller@ctypes.org> - 2013-03-15 12:43 +0100
Re: Unicode Duncan Booth <duncan.booth@invalid.invalid> - 2013-03-15 11:02 +0000
csiph-web