Skip to content

Instantly share code, notes, and snippets.

@jemygraw
Created November 13, 2014 06:30
Show Gist options
  • Save jemygraw/fe7641f435918d081670 to your computer and use it in GitHub Desktop.
Save jemygraw/fe7641f435918d081670 to your computer and use it in GitHub Desktop.
php5 unicode convert raw post data to urlencoded
<?php
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}
$data="fname=jemygraw_999.png\u0026etag=FkbO_BZF_49z0j63-2i1C25QGdT3\u0026key=FkbO_BZF_49z0j63-2i1C25QGdT3\u0026exParam1=w\u0026exParam2=h\u0026exParam3=h";
$data=unicode_decode($data);
echo $data;
@jemygraw
Copy link
Author

fname=jemygraw_999.png&etag=FkbO_BZF_49z0j63-2i1C25QGdT3&key=FkbO_BZF_49z0j63-2i1C25QGdT3&exParam1=w&exParam2=h&exParam3=h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment