Search code examples
phpmysqlutf-8asciifarsi

How to get Persian And Arabic Characters in php


I Want To Get Ascii Code from Persian characters.

My Code:

<?php
header ('Content-Type: text/html; charset=UTF-8'); 
$Char = "س"; // This is a Persian Character
echo ord($Char); // Output: 216
echo ord(utf8_encode($Char)); // Output: 195
// The Real Code Of This Character: 1587
?>

Solution

  • You could use mb_ord() to get the code point of a multibyte character :

    $Char = "س"; // This is a Persian Character
    echo mb_ord($Char); // Output: 1587