3

This is what I want to achieve:

تلر

This is the problem:

$a = "ت";
$l = "ﻝ";
$z = "ر";

$word = $a.$l.$z;
echo $word;

Prints:

ت‌ل‌ر 

while:

echo "تلر";

prints:

تلر

Actually there are no white-spaces but if you try this code (remember to allow utf-8) you will see that the letters won't combine. It works when the letters are combined directly. But as I combine then one by one like: $a.$b.... they wont combine.

Any ideas how I could solve this?

gniourf_gniourf
  • 44,650
  • 9
  • 93
  • 104
Kilise
  • 1,051
  • 4
  • 15
  • 35

2 Answers2

2

Your second single character is U+FEDD while the second character in تلر is U+0644. Use the proper characters and it works:

$a = "ت";
$l = "ل";
$z = "ر";
var_dump("تلر" === $a.$l.$z);

You might want to have a look at How to decode Unicode escape sequences like “\u00ed” to proper UTF-8 encoded characters?

Community
  • 1
  • 1
Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • 1
    You are right. But problem is that if there is no space between `ت` and the next character of it in string it should be automatically converted into the `U+0644`. We can NOT have `U+FEDD` between two characters without spaces. – Arash Milani Dec 26 '12 at 21:34
  • I agree with @Arash Milani – Kilise Dec 27 '12 at 09:35
  • @ArashMilani Well, PHP is not a word processor. It just prints what you tell it to print. – Gumbo Dec 27 '12 at 10:45
0

try to make this encoding instead of utf-8

 <meta http-equiv="Content-Type" content="text/html; charset=windows-1256 "/>

EDIT:

the most popular encoding for arabic language are :

      Windows-1256, ISO 8859-6, and UTF-8.

EDIT: for it will work , you must set your editor also the encoding to windows-1256 and if u are getting strings from database , you must set encoding for database to windows-1256 and should work

echo_Me
  • 37,078
  • 5
  • 58
  • 78