Thanks for everyone help. Done, Finally. Let me share with what I have. Following PHP functions works great for MySQL utf8_unicode_ci data conversion to UTF-8 (hex)
Conclusion:
1. Using JavaScript "encodeURI" to post value to php
2. In PHP request the above-submitted value with out any conversion.
3. Use the following functions to convert the request value
4. This will return UTF-8 (hex), that is the unique reference for the value in DATABASE
PHP Code:
function hex_chars($data) {
$hex = '';
for ($i=0; $i<strlen($data); $i++) {
$c = substr($data, $i, 1);
//$hex .= '{'. hex_format(ord($c)). '}';
$hex .= hex_format(ord($c));
}
return $hex;
}
function hex_format($o) {
$h = strtoupper(dechex($o));
$len = strlen($h);
if ($len % 2 == 1)
$h = "0$h";
return $h;
}
Bookmarks