473,378 Members | 1,417 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,378 software developers and data experts.

addcslashes

Hi everyone,
>From what I understand in of addcslashes, addcslashes should add a
backslash before every character listed in the character list. I've
done a couple of experiments:

echo bin2hex(addcslashes("a","a")) gives 5c31, as expected ('\'
followed by 'a')

Next, I tried

echo bin2hex(addcslashes("\0","\0")); which gave 5c 30 30 30, which is
a backslash followed by 3 spaces. What's happening here? I would have
thought that the output would be

5c 00 (backslash followed by a null)

Taras

Feb 8 '07 #1
3 1450
Next, I tried
>
echo bin2hex(addcslashes("\0","\0")); which gave 5c 30 30 30, which is
a backslash followed by 3 spaces. What's happening here? I would have
thought that the output would be

5c 00 (backslash followed by a null)

Taras
Meh, I re-read the manual more closely and realised that: "while other
non-alphanumeric characters with ASCII codes lower than 32 and higher
than 126 converted to octal representation."

so 5c 30 30 30 = \ octal representation of 0

or, if the byte x01 was escaped, the result would be

5c 30 30 31 = \001 = \ octal representation of 01

What is the point of converting to an octal representation? Where
would it be used? I've never heard of this being used in the c
language..

Taras
Feb 8 '07 #2
"Taras_96" <ta******@gmail.comwrote in message
news:11*********************@s48g2000cws.googlegro ups.com...
Hi everyone,
>>From what I understand in of addcslashes, addcslashes should add a
backslash before every character listed in the character list. I've
done a couple of experiments:

echo bin2hex(addcslashes("a","a")) gives 5c31, as expected ('\'
followed by 'a')
Ascii lowercase 'a' is 0x61, not 0x31. 0x31 is '1'. 0x5c is indeed a
backslash. I got 61 when I tried the line above.
Next, I tried

echo bin2hex(addcslashes("\0","\0")); which gave 5c 30 30 30, which is
a backslash followed by 3 spaces.
0x30 is ascii '0' (zero), not a space (which is 0x20).
What's happening here?
Something quite odd. Since \0 is the string terminating character, it would
seem that it throws the functions a bit off. File a bug report?
Feb 8 '07 #3
On Feb 8, 5:26 pm, "Kimmo Laine" <s...@outolempi.netwrote:
"Taras_96" <taras...@gmail.comwrote in message

news:11*********************@s48g2000cws.googlegro ups.com...
Hi everyone,
>From what I understand in of addcslashes, addcslashes should add a
backslash before every character listed in the character list. I've
done a couple of experiments:
echo bin2hex(addcslashes("a","a")) gives 5c31, as expected ('\'
followed by 'a')

Ascii lowercase 'a' is 0x61, not 0x31. 0x31 is '1'. 0x5c is indeed a
backslash. I got 61 when I tried the line above.
Next, I tried
echo bin2hex(addcslashes("\0","\0")); which gave 5c 30 30 30, which is
a backslash followed by 3 spaces.

0x30 is ascii '0' (zero), not a space (which is 0x20).
What's happening here?

Something quite odd. Since \0 is the string terminating character, it would
seem that it throws the functions a bit off. File a bug report?
You're right about my corrections. For some reason I knew that but I
typed in the wrong things! It's not a bug, it's a documented behavoiur
- see my previous post.

Feb 9 '07 #4

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

Similar topics

3
by: Mark | last post by:
Greetings: So, I've got a real problem in that PHP doesn't seem to be able to unserialize() an array that has an element containing a newline. Of course, I've used htmlentities() to protect the...
2
by: Tim Blackwell | last post by:
i have some php code pulling some data from a database and i need to access some of hte variables in java script. i've never done this before. how can i do it. eg. i'm loading a combo box...
6
by: Spam sucks | last post by:
hello, i want to have an image in a variable so i can show it were ever i want the only catch is that i want the image to be called in the same page, i found this script but the problem is that...
4
by: Brian Murphy | last post by:
I have a php-based yahoo-like web directory.I wanna give webmasters the possiblity to integrate my whole directory in their websites with their own formatting.I wanna this inclusion to be possible...
3
by: Piotr | last post by:
MS has published on its sites javascript encoder, which enables "encrypting" javascript code. It allows hiding js code from being seen as a text file. There is a decoder for it, available in the...
5
by: Micha³ Gancarski | last post by:
Hello! How do one unescape strings prepared with pg_escape_string() ? stripslashes() will not work because both these functions are not completely compatible. Thank you all in advance --...
4
by: Gary | last post by:
Hi, I get this error " " when my web page run, what does it mean? Hope someone can help!!! Gary
3
by: Taras_96 | last post by:
Hi everyone, I'm having a bit of trouble understanding the purpose of escaping nulls, and the use of addcslashes. Firstly, the manual states that: "Strictly speaking, MySQL requires only...
3
by: Alfred | last post by:
I want to post text field data from these HTML TEXTAREA tags to a PostgreSQL database and have it reappear back on another page exactly as I had typed it. Over the years I have done this but only...
1
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...
0
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...
0
isladogs
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
0
BarryA
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.