How to Convert Arabic Characters to Unicode Using PHP
All what you need is function called: utf8Glyphs which you can find it in ArGlyphs.class.php download it from ar-php
and visit Ar-PHP for the ArPHP more information about the project and classes.
This will reverse the word with same of its characters (glyphs).
Example of usage:
<?php
include('Arabic.php');
$Arabic = new Arabic('ArGlyphs');
$text = 'بسم الله الرحمن الرحيم';
$text = $Arabic->utf8Glyphs($text);
echo $text;
?>
PHP: convert arabic word to unicode symbols
// text: العربية
// expected: ﺔﻴﺑﺮﻌﻟﺍ
<?php
$originalText = 'العربية';
$convertedText = mb_convert_encoding($originalText, 'HTML-ENTITIES', 'UTF-8');
$decodedText = html_entity_decode($convertedText);
echo 'Original Text: '. $originalText;
echo '<hr />';
echo 'Converted Text: '. $convertedText;
echo '<hr />';
echo 'Converted Text (display in html): '. htmlentities($convertedText);
echo '<hr />';
echo 'Decoded Text: '. $decodedText;
References:- mb_convert_encoding
- htmlentities
- html_entity_decode
How to convert unicode to arabic characters in php?
I found the solution , hope to help:
function uni2arabic($uni_str)
{
for($i=0; $i<strlen($uni_str); $i+=4)
{
$new="".substr($uni_str,$i,4).";";
$txt = html_entity_decode("$new", ENT_COMPAT, "UTF-8");
$All.=$txt;
}
return $All;
}
variable $All contains the arabic string Php removing unicode arabic characters
Code
$string = 'مُشْكِلَةٌ';
$diacritic = array('ِ', 'ُ', 'ٓ', 'ٰ', 'ْ', 'ٌ', 'ٍ', 'ً', 'ّ', 'َ');
$newString = str_replace($diacritic, '', $string);
echo "Old String : ".$string;
echo "New String : ".$newString;
OutputOld String : مُشْكِلَةٌ
New String : مشكلة
Demo
Arabic characters and UTF-8 in aria2
Try accessing the file or folder via the browser.
By writing a .htaccess-file with the content "Options Indexes" so that you're folders are shown.(I can even access them via http)
I created multiple files and folders by writing a script where the GET Value file or folder determines the name of the folder or file, I tried it with japanese and arabic characters. Albeit they won't be shown in FTP correctly (In my case only file names like: "?????") they are correctly displayed if you read them by script.
The problem might be at the program you're using to access your FTP, WinSCP for example has UTF-8 normally on "auto" by default, so forcing it might work out.(Although I have to admit that it's not working on my side, maybe my linux server is not supporting utf-8 file names which can also be a problem for you)
PS:
Also make sure your php-file is encoded(saved) in UTF-8 without BOM since you're using a constant utf-8 string.
EDIT:
Also if you still intent to use mb_convert_encoding, better add the optional parameter "from_encoding".
I tested this with japanese in a SHIFT-JIS encoded file:
$text = "A strange string to pass, maybe with some 日本語の characters.";
echo mb_convert_encoding($text, 'UTF-8');
and it's not displaying correctly although my browser has UTF-8 activated, so it seems to be not always right when it's trying to detect the Encoding.So this for example works for me then:
$text = "A strange string to pass, maybe with some 日本語の characters.";
echo mb_convert_encoding($text, 'UTF-8', 'SJIS'); //from SJIS(SHIFT-JIS)
This little script is nice to findout the optional parameter you want for your arabic characters:http://www.php.net/manual/de/function.mb-convert-encoding.php#97902
But converting won't be necessary if the file is already in UTF-8, it's only making sense if it's in some arabic encoding, so I think this is not really bringing you any further to the solution.
EDIT2:
Tried a different FTP-Program, Filezilla displays my files and folder, which have japanese names and the arabic one, correctly. (I was using WinSCP 4.3.4 before)
Related Topics
Randomize a PHP Array with a Seed
PHP Require File from Top Directory
Number in the Top-Level Domain
PHP Class Not Found But It's Included
Creating a File Progress Bar in PHP
PHP Pdo Bindparam Was Falling in a Foreach
Dynamic Class Property $$Value in PHP
Type Hinting: Default Parameters
Send Zip File to Browser/Force Direct Download
How to Convert Latin1_Swedish_Ci Data into Utf8_General_Ci
Laravel 5 Auth Post Submit - Tokenmismatchexception in Verifycsrftoken.PHP Line 46
PHP Prepared Statements and Transactions in a Loop
Error Starting Userland Proxy: Listen Tcp 0.0.0.0:3306: Bind: Address Already in Use
How to Select Year and Month from the Created_At Attributes of Database Table in Laravel 5.1
Symfony 3.1.5 Warning: Sessionhandler::Read(): Session Data File Is Not Created by Your Uid