Skip to content
Advertisement

decoding email subject in EXIM log

in my EXIM log I have this email subject

316225317200316271316262316265316262316261316257317211317203316267 316240316261317201316261316263316263316265316273316257316261317202

how can I decode it (human readable) using php ?

Advertisement

Answer

PHP: Strings

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" === "00")
…

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 = "316225317200316271316262316265316262316261316257317211317203316267 316240316261317201316261316263316263316265316273316257316261317202";
echo $double_quoted_string . PHP_EOL;

// octal literal like string (in sigle quotes)
$single_quoted_string = '316225317200316271316262316265316262316261316257317211317203316267 316240316261317201316261316263316263316265316273316257316261317202';
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

Επιβεβαίωση Παραγγελίας
316225317200316271316262316265316262316261316257317211317203316267 316240316261317201316261316263316263316265316273316257316261317202
Επιβεβαίωση Παραγγελίας
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement