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


Groups > comp.lang.python > #100018

RE: Unicode failure

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Albert-Jan Roskam <sjeik_appie@hotmail.com>
Newsgroups comp.lang.python
Subject RE: Unicode failure
Date Fri, 4 Dec 2015 22:49:49 +0000
Lines 19
Message-ID <mailman.210.1449269457.14615.python-list@python.org> (permalink)
References <20151204130738.76313c43@imp>
Mime-Version 1.0
Content-Type text/plain; charset="windows-1256"
Content-Transfer-Encoding base64
X-Trace news.uni-berlin.de KZu4386ZmoZzsLKfJdziUwN7HZ7gx7hzbNmkfKa2880Q==
Return-Path <sjeik_appie@hotmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'sys': 0.05; '-*-': 0.07; '-0500': 0.07; 'skip:/ 10': 0.07; 'utf-8': 0.07; 'coding:': 0.09; 'encode': 0.09; 'python': 0.10; '&gt;&gt;&gt;': 0.15; 'codec': 0.16; 'missing?': 0.16; 'ordinal': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'stuff.': 0.16; 'subject:Unicode': 0.16; 'script.': 0.18; 'string,': 0.18; '>>>': 0.20; '2015': 0.20; 'to:2**1': 0.21; 'seems': 0.23; 'dec': 0.23; 'import': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'raw': 0.27; 'to:no real name:2**1': 0.27; 'skip:u 20': 0.28; 'character': 0.29; 'url:mailman': 0.30; 'date:': 0.31; "can't": 0.32; 'url:python': 0.33; 'traceback': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'unicode': 0.35; 'subject:': 0.35; 'skip:p 30': 0.35; 'but': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thought': 0.37; 'from:': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'mark': 0.40; 'still': 0.40; 'skip:u 10': 0.61; 'here': 0.66; 'email name:python-list': 0.67; 'charset:windows-1256': 0.67; '3.4': 0.84
X-TMN [eKUSJCW1gyiZ2SOiOvcYvUIVE1731hL3]
X-Originating-Email [sjeik_appie@hotmail.com]
Importance Normal
In-Reply-To <20151204130738.76313c43@imp>
X-OriginalArrivalTime 04 Dec 2015 22:49:49.0964 (UTC) FILETIME=[14F87CC0:01D12EE6]
X-Content-Filtered-By Mailman/MimeDel 2.1.20+
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:100018

Show key headers only | View raw


I think you need to use a raw unicode string, ur

>>> unicodedata.name(ur'\u2122')
'TRADE MARK SIGN'

> Date: Fri, 4 Dec 2015 13:07:38 -0500
> From: darcy@VybeNetworks.com
> To: python-list@python.org
> Subject: Unicode failure
> 
> I thought that going to Python 3.4 would solve my Unicode issues but it
> seems I still don't understand this stuff.  Here is my script.
> 
> #! /usr/bin/python3
> # -*- coding: UTF-8 -*-
> import sys 
> print(sys.getdefaultencoding()) 
> print(u"\N{TRADE MARK SIGN}") 
> 
> And here is my output.
> 
> utf-8
> Traceback (most recent call last):
>   File "./g", line 5, in <module>
>     print(u"\N{TRADE MARK SIGN}")
> UnicodeEncodeError: 'ascii' codec can't encode character '\u2122' in
> position 0: ordinal not in range(128)
> 
> What am I missing?
> 
> TIA.
> 
> -- 
> D'Arcy J.M. Cain
> Vybe Networks Inc.
> http://www.VybeNetworks.com/
> IM:darcy@Vex.Net VoIP: sip:darcy@VybeNetworks.com
> -- 
> https://mail.python.org/mailman/listinfo/python-list
 		 	   		  

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


Thread

RE: Unicode failure Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2015-12-04 22:49 +0000

csiph-web