解码 EXIM 日志中的电子邮件主题
decoding email subject in EXIM log
在我的 EXIM 日志中我有这个电子邮件主题
6570616265626167717367 6061716163636563676172
如何使用 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. "0" === "[=10=]0")
…
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.
以下代码片段显示了 double- 和 single- 引号字符串的示例。后者使用preg_replace_callback
function转换(使用回调执行正则表达式搜索和替换):
<?php
// octal literal (in double quotes)
$double_quoted_string = "6570616265626167717367 6061716163636563676172";
echo $double_quoted_string . PHP_EOL;
// octal literal like string (in sigle quotes)
$single_quoted_string = '6570616265626167717367 6061716163636563676172';
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;
?>
输出:72104296.php
Επιβεβαίωση Παραγγελίας
6570616265626167717367 6061716163636563676172
Επιβεβαίωση Παραγγελίας
在我的 EXIM 日志中我有这个电子邮件主题
6570616265626167717367 6061716163636563676172
如何使用 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. "0" === "[=10=]0") …
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.
以下代码片段显示了 double- 和 single- 引号字符串的示例。后者使用preg_replace_callback
function转换(使用回调执行正则表达式搜索和替换):
<?php
// octal literal (in double quotes)
$double_quoted_string = "6570616265626167717367 6061716163636563676172";
echo $double_quoted_string . PHP_EOL;
// octal literal like string (in sigle quotes)
$single_quoted_string = '6570616265626167717367 6061716163636563676172';
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;
?>
输出:72104296.php
Επιβεβαίωση Παραγγελίας
6570616265626167717367 6061716163636563676172
Επιβεβαίωση Παραγγελίας