php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #20231 \v C-style escape sequence in double-quoted strings
Submitted: 2002-11-03 15:19 UTC Modified: 2012-09-23 16:57 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: hioreanu+php at uchicago dot edu Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 4.2.2 OS: Linux, FreeBSD
Private report: No CVE-ID: None
 [2002-11-03 15:19 UTC] hioreanu+php at uchicago dot edu
PHP does not seem to recognize the "\v" escape sequence within strings, like C does.  This would probably be an issue in the PHP double-quoted string parser.

I'm guessing this has been filed elsewhere as a bug, but I cannot find it (the bug search form does not like \v, '\v' or "\v").

Even though this is documented (language.types.string.php), it is still unexpected.  Consider the following code:

$s = ereg_replace("[\t\v\n\r ]", '', $s);

The intent is to replace all whitespace, where whitespace is defined similarly to isspace(3) (but I forgot '\f', no big deal).  The result is that whitespace *and* the "v" character is removed.  The letter v is rare enough in English (and vertical tab is almost unheard-of in text) that this can go for a few days without being noticed.

In the same vein, \f should also be recognized.  I'm not sure about \a and \b, but I would definitely say trigraphs are a bad idea :).

Perhaps only a warning would be enough.  My copy of the C standard states that when an unknown escape sequence is encountered, the compiler should emit a diagnostic.  That seems like reasonable behaviour.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-23 16:57 UTC] nikic@php.net
Closing as both \v and \f are supported by now.
 [2012-09-23 16:57 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 11:01:30 2024 UTC