473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

convert string to the "escaped string"

I am trying to convert string to the "escaped string".
example: from "0xf" I need "\0xf"
I am able to do it like:

escaped_a=("\%s" % a ).decode("string_escape")

But it looks a little bit complicated in this beautiful language to me


Petr Jakes

Nov 22 '05 #1
3 3409
small mistake in my previous posting, sorry!!!!
from "0xf" I need "\xf" of course
and mentioned code gives me "\0xf" of course.

Thanks for your postings

Petr Jakes

Nov 22 '05 #2
Petr Jakes wrote:
I am trying to convert string to the "escaped string".
example: from "0xf" I need "\0xf" I am able to do it like:

escaped_a=("\%s" % a ).decode("string_escape")

But it looks a little bit complicated in this beautiful language to me

I suspect that optimizing for people who want to turn "0xf" into
chr(0) + "xf" isn't exactly a priority...

if that's really what you want, of course. are you sure you didn't
mean to write, say

chr(int("0xf", 0))

(that is, convert 0xf to a character) or

repr(chr(int("0xf", 0)))

(that is, convert 0xf to a character, and convert that character to a
string literal)



Nov 22 '05 #3
Fredrik, thanks for your posting. I really appretiate your reply and
your way how you kindly answer even stupid newbie's questions on this
mailing list.
I was trying: int("0xf") but I did not have idea about the optional
"base" parameter for the int function.
Thanks a lot.

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Ed Sutton | last post by:
Is there an easy conversion from a hex string, for example "0x1234" to an int? I have written my own many times in other languages, I was just wondering if there might be something already...
by: Ping | last post by:
Hi, All, We can use BitConverter.ToString(byte) to a string, but how to get the byte from a string like "AD-A6-0D-1F"?
by: privetv7 | last post by:
ppl... HELP!!!!! i don't know how to convert String into char..... for example i can do String input; int number; input = JOptionPane.showInputDialog( "Enter what ever" ); number =...
by: chongo | last post by:
Hi, i'm reading in a bigint value from SQL Server. string s = myReader.ToString()); int intBackColour = System.Convert.ToInt32(s); I'm also reading in other values the same way and it...
by: Joebloggs | last post by:
Hi I am trying to do an ldap lookup. I can pick up the domain name in the standard format DOMAIN\USERNAME. The problem is the company I work for expects the query in the format DOMAIN:USERNAME....
by: ondekoza | last post by:
Hello, I need to convert the string "FFFFFFFF" to a long. To convert this string I tried the following: >>> 0xffffffff -1 >>> 0xffffffffL 4294967295L OK, this is what I want, so I tried
by: =?Utf-8?B?RWxlbmE=?= | last post by:
I am surprised to discover that c# automatically converts an integer to a string when concatenating with the "+" operator. I thought c# was supposed to be very strict about types. Doesn't it seem...
by: yabansu | last post by:
Hi all, I think most of you probably know the two .NET framework functions, namely Encoding.GetBytes(string) and Encoding.GetString(byte), to convert string into byte array and vice versa. Now,...
by: Just Another Victim of the Ambient Morality | last post by:
I've done a google search on this but, amazingly, I'm the first guy to ever need this! Everyone else seems to need the reverse of this. Actually, I did find some people who complained about this...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.