Unicode Numeric figure converstion

Now a day, many open source packages are translating in Bangla. This is usually done by replacing the language file with equivalent Bangla language’s Unicode value. But problem is that the numeric figures are still in English. I faced this problem in Projanmo Forum. So today I make a script to convert these English numeric figures to Bangla.

function convert($char){

switch($char){
case "1":
return "১";
break;
case "2":
return "২";
break;
case "3":
return "৩";
break;
case "4":
return "৪";
break;
case "5":
return "৫";
break;
case "6":
return "৬";
break;
case "7":
return "৭";
break;
case "8":
return "৮";
break;
case "9":
return "৯";
break;
case "0":
return "০";
break;
default:
return $char;
break;

}
}

function unicode($str){
$count=strlen($str);
$uni='';
for($i=0;$i<$count;$i++){
if(is_int($i)){
$uni.=convert(substr($str,$i,1));
}
}

return $uni;
}

?>

After putting this code in a file, you have to include with any existing php file from where you wanna call this function.

Suppose there is a code in your forum or any other script:

echo $num;
?>

which produces 100 for example.

Now use

echo unicode($num);
?>

So, this will show 100 in Bengali (Bangla).

Thats it :).

Update (06/12/2007):
Version 2x is now available. Now Day Name (Sun, Mon etc.) and Month Name (Jan, Feb etc.) will also be Converted to Bangla.
Download the attachment for the full script.