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.

<?php
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:

<?php
echo $num;
?>

which produces 100 for example.

Now use

<?php
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.

AttachmentSize
e2bconvert.zip938 bytes

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

Can I use this in SMF or is

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

ahhh... very easy one... i

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

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.

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....

Wow..... That's Gra8.

Wow..... That's Gra8.

ভাল

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

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><div><img>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Use the special tag [adsense:format:group:channel] or [adsense:flexiblock:location] to display Google AdSense ads.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Powered by Drupal - Design by artinet