Hi guys
Short:
I get character ascii code 194 as the first character in $message, even though the text starts with a space.
I am thus unable to get a regexp working, which looks for surrounding spaces around a URL.
Long:
I wanted to create a very basic plugin that do some regexp replace on a post. I use the parse_message_start hook as documented here.
After spending a while trying to debug my regexp I tried this simple hook:
The text in the message begins exactly like this: (one space character)test
The result after clicking Preview is this:
Why does $message starts with ascii code 194, and thus unable to match \s in a regexp, when the message actually starts with a space?
Could this be an issue with utf-8 parsing?
ps: this first answer seems to explain the code 194 (0xC2) http://stackoverflow.com/questions/14310...aracter-is should I expect the "non breaking space" character at the start of a message? Is there a way to get a regular space character instead?
The non-breaking whitespace at beginning of $message can be removed with this hack :
Short:
I get character ascii code 194 as the first character in $message, even though the text starts with a space.
I am thus unable to get a regexp working, which looks for surrounding spaces around a URL.
Long:
I wanted to create a very basic plugin that do some regexp replace on a post. I use the parse_message_start hook as documented here.
After spending a while trying to debug my regexp I tried this simple hook:
function SomePlugin_hook($message)
{
$message = "first char code = ".ord($message);
return $message;
}
The text in the message begins exactly like this: (one space character)test
The result after clicking Preview is this:
first char code = 194
Why does $message starts with ascii code 194, and thus unable to match \s in a regexp, when the message actually starts with a space?
Could this be an issue with utf-8 parsing?
ps: this first answer seems to explain the code 194 (0xC2) http://stackoverflow.com/questions/14310...aracter-is should I expect the "non breaking space" character at the start of a message? Is there a way to get a regular space character instead?
The non-breaking whitespace at beginning of $message can be removed with this hack :
$message = preg_replace('/^\x{00a0}+/ui', '', $message);