Unicode Numeric figure converstion

Thursday May 31stOpen Source, Scripts Category



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.

[code]
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;
}

?>
[/code]

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:

[code]
echo $num;
?>
[/code]

which produces 100 for example.

Now use
[code]
echo unicode($num);
?>
[/code]

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.

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

No related posts.

10 Comments

  1. Arafat Rahman
    June 3, 2007

    ভাল
    ভাল লিখছেন ….
    সুন্দর লিখছেন…..

  2. Sharif Abdullah
    June 1, 2007

    Wow….. That’s Gra8.

    Wow….. That’s Gra8.

  3. TRIVUz
    December 8, 2007

    ahhh… very easy one… i
    ahhh… very easy one… i lyk this one… great job! :-)

  4. Rajib Rahman
    October 29, 2007

    that’s really cool
    that’s really cool script….and very useful also…
    i am really enjoying it…thanks a lot hungrycoder(Raju bahi)
    for your post….

  5. hungrycoder
    October 29, 2007

    problem is that browser is
    problem is that browser is showing the ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯ ০ instead of their unicode entity in the above code. you have to put unicode value instead of real bangla characters or you can save your document as unicode.

  6. তনয়
    April 1, 2008

    Can I use this in SMF or is
    Can I use this in SMF or is it created only for Punbb?

  7. hungrycoder
    April 1, 2008

    yes, you can use it in SMF
    yes, you can use it in SMF too. this could be used anywhere.

    you just bind a variable by this function. for example.

    if the code is:
    < ?php echo $num_posts; ?>

    you simply make it:
    < ?php echo unicode($num_posts); ?>

    thats it.

    thanks

  8. Arafat Rahman
    September 11, 2008

    very easy one

  9. মুকুল
    December 29, 2009

    এটা ওয়ার্ডপ্রেসে কিভাবে ব্যবহার করবো?
    ওয়ার্ডপ্রেসের সব ইংরেজী সংখ্যা বাংলায় দেখাতে এটা কি কাজ করবে ?

  10. admin
    January 9, 2010

    @Mukul,
    You may write a plugin that will do what you want!

Leave a comment

morshed unicode converter bd - echo unicode return when -

Size

Colors