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


Groups > comp.lang.python > #32981

RE: Right solution to unicode error?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'completeness': 0.07; 'abstraction': 0.09; 'encoding.': 0.09; 'received:155': 0.09; 'subject:error': 0.11; 'encoding': 0.15; '"import': 0.16; '"level"': 0.16; '11:32': 0.16; 'benjamin': 0.16; 'correctly,': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:159.53.110': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'subject:unicode': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'value"': 0.16; 'wrongly': 0.16; '\xc3\xa9crit\xc2\xa0:': 0.16; 'translation': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'unicode': 0.17; '>>>': 0.18; '(or': 0.18; 'windows': 0.19; 'to:name:python-list@python.org': 0.20; "skip:' 40": 0.22; 'to:2**1': 0.23; 'seems': 0.23; 'received:169.254': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'values': 0.26; 'am,': 0.27; 'accuracy': 0.27; '--------': 0.28; 'character.': 0.29; 'character': 0.29; 'definition': 0.29; 'received:169': 0.29; 'related': 0.30; 'up.': 0.31; 'code': 0.31; "skip:' 20": 0.32; 'right?': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'nov': 0.35; 'subject:?': 0.35; 'but': 0.36; 'characters': 0.36; 'display': 0.36; 'does': 0.37; 'option': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'nothing': 0.38; 'page': 0.38; 'gives': 0.39; 'instead': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; 'skip:u 10': 0.60; 'real': 0.61; 'map': 0.61; 'between': 0.63; 'different': 0.63; 'email addr:gmail.com': 0.63; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'sale': 0.76; 'console,': 0.84; 'novembre': 0.84; 'oscar': 0.84; 'received:169.254.8': 0.84; 'visually': 0.84
X-DKIM OpenDKIM Filter v2.1.3 sj3.jpmchase.com qA8KsdAr025767
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1352408079; bh=bcZSxnPm6N4zUrZ5ug/FwEte5BCQex3Ewh464zb3idI=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=DE+bwziMDEK4kgvxIhRHTIAmoy0ntEGAB9thJI1sP+K10vGQm9Phhk8JcpHxSLAh5 QjEpjtYiGquqIBiQ2iNmrRBwnYUaVNwH7juOtetC+eT14slm7VIw3UxL6BuV30OV3E 2lQDxYaik8+EP0t1dA6hXnP2SBaI6MorfsU5V6lQ=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "wxjmfauth@gmail.com" <wxjmfauth@gmail.com>, "python-list@python.org" <python-list@python.org>
Subject RE: Right solution to unicode error?
Thread-Topic Right solution to unicode error?
Thread-Index AQHNverZ/xR6HEvFT06wM53mT6A/j5fgXSlw
Date Thu, 8 Nov 2012 20:54:23 +0000
References <09a3d20b-5871-47f4-9218-df119698e405@m4g2000yqf.googlegroups.com> <CAHVvXxT8SpK24HtsS8XTfs0CHTBofh3=deYw5xY1nq5ctATjrg@mail.gmail.com> <509AF3EF.8050108@gmail.com> <CAHVvXxSg0XWjZmA1pnEvBB_b2T9pS91YdjhF2duZHmBuLbXNAw@mail.gmail.com> <mailman.3436.1352383603.27098.python-list@python.org> <65910cea-f145-409c-a579-9f0cda499546@googlegroups.com> <CAHVvXxT9msy1HMwTtJBwGCXM_gKwtovOV5dNUQUYcugdoypWtw@mail.gmail.com> <mailman.3459.1352400535.27098.python-list@python.org> <a0073458-3b60-4c19-909d-c3d6dda7dccc@googlegroups.com>
In-Reply-To <a0073458-3b60-4c19-909d-c3d6dda7dccc@googlegroups.com>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.47]
Content-Transfer-Encoding base64
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="utf-8"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3466.1352408089.27098.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352408089 news.xs4all.nl 6955 [2001:888:2000:d::a6]:53339
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32981

Show key headers only | View raw


wxjmfauth@gmail.com wrote:
> 
> Le jeudi 8 novembre 2012 19:49:24 UTC+1, Ian a écrit :
> > On Thu, Nov 8, 2012 at 11:32 AM, Oscar Benjamin
> >
> > <oscar.j.benjamin@gmail.com> wrote:
> >
> > > If I want the other characters to work I need to change the code page:
> > >
> > > O:\>chcp 65001
> > > Active code page: 65001
> > >
> > > O:\>Q:\tools\Python33\python -c "import sys;
> > > sys.stdout.buffer.write('\u03b1\n'.encode('utf-8'))"
> > > α
> > >
> > > O:\>Q:\tools\Python33\python -c "import sys;
> > > sys.stdout.buffer.write('\u03b1\n'.encode(sys.stdout.en
> > > coding))"
> > > α
> >
> > I find that I also need to change the font.  With the default font,
> >
> > printing '\u2013' gives me:
> > –
> >
> > The only alternative font option I have in Windows XP is Lucida
> > Console, which at least works correctly, although it seems to be
> > lacking a lot of glyphs.
> 
> --------
> 
> Font has nothing to do here.
> You are "simply" wrongly encoding your "unicode".
> 


Why would font not matter? Unicode is the abstract definition 
of all characters right? From that we map the abstract 
character to a code page/set, which gives real values for an
abstract character. From that code page we then visually display 
the "real value" based on the font. If that font does
not have a glyph for a specific character page (or a different
glyph) then that is a problem and not related encoding. 

Unicode->code page->font


> >>> '\u2013'
> '–'
> >>> '\u2013'.encode('utf-8')
> b'\xe2\x80\x93'
> >>> '\u2013'.encode('utf-8').decode('cp1252')
> '–'
> 

This is a mismatched translation between code pages; not
font related but is instead one abstraction "level" up. 


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

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


Thread

Right solution to unicode error? Anders <aschneiderman@asha.org> - 2012-11-07 14:17 -0800
  RE: Right solution to unicode error? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-07 23:07 +0000
  Re: Right solution to unicode error? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-07 23:27 +0000
  Re: Right solution to unicode error? Andrew Berg <bahamutzero8825@gmail.com> - 2012-11-07 17:51 -0600
  Re: Right solution to unicode error? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-07 23:53 +0000
    Re: Right solution to unicode error? Hans Mulder <hansmu@xs4all.nl> - 2012-11-08 12:40 +0100
  Re: Right solution to unicode error? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-08 00:44 +0000
  Re: Right solution to unicode error? wxjmfauth@gmail.com - 2012-11-08 03:01 -0800
  RE: Right solution to unicode error? Anders Schneiderman <ASchneiderman@asha.org> - 2012-11-08 09:00 -0500
  Re: Right solution to unicode error? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-08 14:06 +0000
    Re: Right solution to unicode error? wxjmfauth@gmail.com - 2012-11-08 07:05 -0800
      Re: Right solution to unicode error? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-08 18:32 +0000
        Re: Right solution to unicode error? wxjmfauth@gmail.com - 2012-11-08 11:30 -0800
        Re: Right solution to unicode error? wxjmfauth@gmail.com - 2012-11-08 11:30 -0800
      Re: Right solution to unicode error? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 11:48 -0700
        Re: Right solution to unicode error? wxjmfauth@gmail.com - 2012-11-08 11:54 -0800
          Re: Right solution to unicode error? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 13:41 -0700
            Re: Right solution to unicode error? wxjmfauth@gmail.com - 2012-11-09 02:06 -0800
          RE: Right solution to unicode error? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-08 20:54 +0000
          Re: Right solution to unicode error? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 14:07 -0700
          Re: Right solution to unicode error? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-08 21:37 +0000
        Re: Right solution to unicode error? wxjmfauth@gmail.com - 2012-11-08 11:54 -0800
  Re: Right solution to unicode error? Andrew Berg <bahamutzero8825@gmail.com> - 2012-11-08 21:30 -0600

csiph-web