in my EXIM log I have this email subject
\316\225\317\200\316\271\316\262\316\265\316\262\316\261\316\257\317\211\317\203\316\267 \316\240\316\261\317\201\316\261\316\263\316\263\316\265\316\273\316\257\316\261\317\202
how can I decode it (human readable) using php ?
A string is series of characters…
…
If the string is enclosed in double-quotes ("
), PHP will interpret the following escape sequences for special characters:Escaped characters
Sequence Meaning … \[0-7]{1,3} the sequence of characters matching the regular expression is a character in octal notation, which silently overflows to fit in a byte (e.g. "\400" === "\000") …
Note: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.
The following code snippet shows examples for both double- and single- quoted strings. The latter is converted using preg_replace_callback
function (Perform a regular expression search and replace using a callback):
<?php
// octal literal (in double quotes)
$double_quoted_string = "\316\225\317\200\316\271\316\262\316\265\316\262\316\261\316\257\317\211\317\203\316\267 \316\240\316\261\317\201\316\261\316\263\316\263\316\265\316\273\316\257\316\261\317\202";
echo $double_quoted_string . PHP_EOL;
// octal literal like string (in sigle quotes)
$single_quoted_string = '\316\225\317\200\316\271\316\262\316\265\316\262\316\261\316\257\317\211\317\203\316\267 \316\240\316\261\317\201\316\261\316\263\316\263\316\265\316\273\316\257\316\261\317\202';
echo $single_quoted_string . PHP_EOL;
function tochrs($matches) {
return chr(intval(ltrim($matches[0], '\\'), 8));
};
$regex = "/\\\\[0-7]{3}/";
echo preg_replace_callback($regex, "tochrs", $single_quoted_string) . PHP_EOL;
?>
Output: 72104296.php
Επιβεβαίωση Παραγγελίας
\316\225\317\200\316\271\316\262\316\265\316\262\316\261\316\257\317\211\317\203\316\267 \316\240\316\261\317\201\316\261\316\263\316\263\316\265\316\273\316\257\316\261\317\202
Επιβεβαίωση Παραγγελίας