LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-21-2002, 08:24 AM   #1
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
python: converting a 3 character octal string into an ASCII char


OK, I'm trying to go through a string and replace all occurences of %xxx (where x is an octal digit) with the coresponding ASCII character.

Two problems:

I can't work out how to convert the string xxx into a number (string.atoi is for decimal numbers).

curses.ascii.unctrl(), which is supposed to convert a number into its corresponding character doesn't seem to work properly. For example, it treats 65 (decimal) as a control code, and returns some weird string that isn't 'A'. Documentation for it is at http://www.python.org/doc/current/li...ses.ascii.html

Alex

Last edited by llama_meme; 08-21-2002 at 08:33 AM.
 
Old 07-06-2010, 02:00 PM   #2
threebean
LQ Newbie
 
Registered: Jul 2010
Posts: 1

Rep: Reputation: 0
You can use string.atoi(s, base=8) for octal numbers.
 
  


Reply


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
renaming file with escaped ascii, octal or anything whansard Linux - General 2 08-07-2005 08:59 AM
C++: char* to string, converting? rewriting program? need substr! lrt2003 Programming 2 06-19-2004 03:20 AM
Have problem converting a decimal number to octal Linh Programming 4 05-20-2004 03:21 PM
Can 't convert from a character to octal value in memory Linh Programming 2 07-21-2003 03:11 PM
ASCII char mapping tlennon Linux - Newbie 0 03-05-2001 07:10 PM


All times are GMT -5. The time now is 10:37 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