php - How to decode hex content? -
i have $_server['redirect_ssl_client_s_dn'] content has somekind of hex data. how can decode it?
$_server['redirect_ssl_client_s_dn'] = '../cn=\x00m\x00\xc4\x00,\x00i\x00s\x00,\x004\x000\x003\x001\x002\x000\x000\x002/sn=..'; $pattern = '/cn=(.*)\\/sn=/'; preg_match($pattern, $_server['redirect_ssl_client_s_dn'], $server_matches); print_r($server_matches[1]); the result is:
\x00m\x00\xc4\x00,\x00i\x00s\x00,\x004\x000\x003\x001\x002\x000\x000\x002
the result need is:
mÄ,is,40312002
i tried decode chr(hexdec($value)); , works, in html input see lot of question marks.
edit: additional test results. not yet perfect. array reveals errors: http://pastebin.com/bc4xxqme
after using utf8_encode, have multibyte string. means need use php's multibyte (mb_) functions.
so, str_split won't work anymore. need use either mb_split or preg_split u flag.
$splitted = preg_split('//u', $string); here's demo showing code working: http://ideone.com/nqec0u
Comments
Post a Comment