This the code in python
value.py
print('Print 😀 Smile 🥇 2nd Best Private'.encode('utf-8'))
# b'Print \xf0\x9f\x98\x80 Smile \xf0\x9f\xa5\x87 2nd Best Private'
value.php
#get value from value.py
$bio=rtrim(ltrim($temp[2]));
$bio = preg_replace("/U\+([0-9a-f]{4,5})/mi", '&#x${1}', $bio);
echo ($bio);
echo($bio);
//output = \xf0\x9f\x98\x80 Smile \xf0\x9f\xa5\x87 2nd Best Private'
Here's my naive approach (implemented in Windows).
Scripts :
type .\SO\71805811.py
# -*- coding: utf-8 -*- print('Print Smile 2nd Best Private'.encode('utf-8'))
type .\SO\71805811.php
<?php var_dump($argn); $pattern = '(\\\\x(?=[0-9A-Fa-f]{2}))'; // ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ positive lookahead assertion $replacement = '='; $encoded = preg_replace($pattern, $replacement, $argn); var_dump(quoted_printable_decode($encoded)); ?>
Output :
.\SO\71805811.py
b'Print \xf0\x9f\x98\x80 Smile \xf0\x9f\xa5\x87 2nd Best Private'
.\SO\71805811.py | \php8\php.exe -F .\SO\71805811.php
string(65) "b'Print \xf0\x9f\x98\x80 Smile \xf0\x9f\xa5\x87 2nd Best Private'" string(41) "b'Print Smile 2nd Best Private'"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.