LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-02-2008, 12:08 AM   #1
donnied
Member
 
Registered: Oct 2006
Distribution: Debian x64
Posts: 198

Rep: Reputation: 30
python: using a variable to print unicode character


I'd like to do something like:
g = 0000
while g < ffff
g = g+0001
print u'\u\g'
The question is: (how) can I have python evaluate the variable g and print the corresponding unicode character?
 
Old 02-03-2008, 02:06 PM   #2
traene
Member
 
Registered: Jan 2005
Distribution: Archlinux, Debian, grml
Posts: 210

Rep: Reputation: 33
I haven't tried that, but maybe the unicode package will help:
Code:
print unicode.name(g)
 
Old 02-04-2008, 12:31 AM   #3
angrybanana
Member
 
Registered: Oct 2003
Distribution: Archlinux
Posts: 147

Rep: Reputation: 21
Code:
start = '0000'
stop  = 'ffff'

for i in range(int(start, 16), int(stop, 16)):
    print unichr(i)
 
Old 02-09-2008, 03:51 AM   #4
donnied
Member
 
Registered: Oct 2006
Distribution: Debian x64
Posts: 198

Original Poster
Rep: Reputation: 30
excellent suggestion

Thank you. That really simplified the code. I won't say what I had done before, but your response was similar to a shell script I had used to create the data files used to create individual classes. doh.

Now, I will work on two more aspects:
directing the output to a formatted window using glade
providing a way to select/import fonts
 
  


Reply

Tags
python, unicode, variables


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unicode Character Check in Perl gjagadish Programming 2 08-22-2007 12:31 AM
[Bash] New line character in variable michael_hk Linux - Newbie 4 06-15-2006 03:13 PM
unicode & frensh character ! ik@z Linux - General 1 05-17-2006 01:07 AM
php unicode global variable jayakrishnan Programming 1 03-10-2006 05:19 PM
lp print- alt196 character paulmccs Programming 0 03-08-2002 10:40 AM


All times are GMT -5. The time now is 01:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration