![](/img/trans.png)
[英]converting unicode \u sequence (like \u041a) to normal utf-8 text in php
[英]PHP converting PCRE unicode sequence to normal utf-8 string
在PHP中是否可以將Unicode PCRE序列(例如\\x{2f}
, \\x{3251}
)轉換為字符串?
function cb($a){
$num = $a[1];
$dec = hexdec($num);
return "&#$dec;";
}
$ent = preg_replace_callback("/\\\\x\{([\da-z]+)\}/i", 'cb', "\x{2f}, \x{3251}");
$ustr = html_entity_decode($ent, ENT_NOQUOTES, 'UTF-8');
樣本: http : //ideone.com/fDNGM
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.