note 34041 added to function.stripcslashes
| From: | abodeman at rack1 dot php dot net | Date: | Mon, 14 Jul 2003 17:27:38 +0000 |
| Subject: | note 34041 added to function.stripcslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52092@lists.php.net to get a copy of this message | ||
stripcslashes does not accept hexadecimal escape sequences of more than two digits, even though C
does. This means that all of the following are true (in C the second and third examples would
contain the characters '\x48e' and '\x323' respectively):
stripcslashes('H\x65llo') == 'Hello'
stripcslashes('\x48ello') == 'Hello'
stripcslashes('1\x323') == '123'
stripcslashes does accept hexadecimal escape sequences of only one digit, as long as the following
digit is not a valid hexadecimal digit, so both of the following are true:
stripcslashes('He\xallo') == 'He'."\n".'llo'
stripcslashes('H\xaello') == 'H'.chr(0xAE).'llo'
The fact that stripcslashes is limited to two hexadecimal digits looks like a bug at first glance,
but it can be a feature. You can, for example, do a simple str_replace(':',
'\x3a', $str) to replace all colons in a string with '\x3a' without having to
worry about whether or not the next character will be interpreted as a hexadecimal digit.
If this "bug" is ever fixed, there will be no way in PHP to escape the colon in the string
'a:b' with a hexadecimal representation, since the 'b' would be interpreted as
the hexadecimal digit 11. The string 'a\x3ab' would be interpreted as
'a'.chr(0x3AB).
----
Manual Page -- http://www.php.net/manual/en/function.stripcslashes.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34041
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34041&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34041&report=yes