Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: convert unicode characters to visibly similar ascii characters

Reply
Thread Tools

Re: convert unicode characters to visibly similar ascii characters

 
 
Terry Reedy
Guest
Posts: n/a
 
      07-01-2008


Peter Bulychev wrote:
> Hello.
>
> I want to convert unicode character into ascii one.
> The method ".encode('ASCII') " can convert only those unicode
> characters, which fit into 0..128 range.
>
> But there are still lots of characters beyond this range, which can be
> manually converted to some visibly similar ascii characters. For
> instance, there are several quotation marks in unicode, which can be
> converted into ascii quotation mark.
>
> Can this conversion be performed in automatic manner? After googling
> I've only found that there exists Unicode database, which stores
> human-readable information on notation of all unicode characters
> (ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt). And there also
> exists the Python adapter for this database
> (http://docs.python.org/lib/module-unicodedata.html). Using this
> database I can do something like `if
> notation.find('QUOTATION')!=-1:\n\treturn "'"`. I believe there is more
> elegant way. Am I right?


I believe you will have to make up your own translation dictionary for
the translations *you* want. You should then be able to use that with
the .translate() method.

tjr

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert PCL5 to PDF, Display UNICODE & ASCII Characters Inside PDF sherazam Java 0 02-22-2011 08:42 AM
Python unicode utf-8 characters and MySQL unicode utf-8 characters Grzegorz Śliwiński Python 2 01-19-2011 07:31 AM
Re: convert unicode characters to visibly similar ascii characters Laszlo Nagy Python 6 07-02-2008 04:42 PM
Re: convert unicode characters to visibly similar ascii characters M.-A. Lemburg Python 0 07-02-2008 08:39 AM
[FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127) Alextophi Perl Misc 8 12-30-2005 10:43 AM



Advertisments