i need a function or a simple algo to help me convert a normal string to utf-8 code
ex: string:
hello
عربي
UTF-8 CODE:
68 65 6C 6C 6F 0A 0639 0631 0628 064A 0A
i need a function or a simple algo to help me convert a normal string to utf-8 code
ex: string:
hello
عربي
UTF-8 CODE:
68 65 6C 6C 6F 0A 0639 0631 0628 064A 0A
use the utf8_encode ( $data )
see its full documentation http://php.net/manual/en/function.utf8-encode.php
Use iconv
, as shown:
$text = iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text);
This is also detects the strings current character set.
Try to use iconv
funcion here is description
if you want to use it with arabic
you can use arabic php library at : http://ar-php.org/
Try This:
...
$somStr = 'Hello';
utf8_encode_deep($somStr); // Converting string to utf8
print_r($somStr);
...
For more details regarding utf8_encode_deep()
see this
Hope it solves this problem.