why are arabic numbers (١٢٣) not accepted in textboxes as real numbers?
AFAIK you need to install an arabic language pack with ./mage install
- see http://www.magentocommerce.com/magento-connect/Ahmed+J.+Hadi/extension/353/magento-community-modules--arabic-saudi-arabia-language-pack
To allow PHP to accept the Arabic numbers or Persian numbers (Farsi) (١٢٣٤٥), I developed this easy function:
<?php
/*
/////////////////////
This function has been created by Abdulfattah alhazmi
Roles:
To convert Arabic/Farsi Numbers (٠ - ١ - ٢ - ٣ - ٤ - ٥ - ٦ - ٧ - ٨ - ٩)
TO the corrosponding English numbers (0-1-2-3-4-5-6-7-8-9)
http://hazmi.co.cc
/////////////////////
*/
function convertArabicNumbers($arabic) {
$trans = array(
"٠" => "0",
"١" => "1",
"٢" => "2",
"٣" => "3",
"٤" => "4",
"٥" => "5",
"٦" => "6",
"٧" => "7",
"٨" => "8",
"٩" => "9",
);
return strtr($arabic, $trans);
}
?>
Note: TO GET THE CORRECT RESULT from text field in your form, you have to use the htmlspecialchars_decode()
function. For example:
$mytext = htmlspecialchars_decode($_POST['mytext']));
$mytext = convertArabicNumbers($mytext);
To keep your code safe, add strip_tags()
. For example:
$mytext = strip_tags(htmlspecialchars_decode($_POST['mytext']));
$mytext = convertArabicNumbers($mytext);
Please don't hesitate to ask me if you have any further question about this function.