Faqts

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 20 people (30%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How do I remove all accent from a string ?
Is there a STRTR function like in php ?

Sep 12th, 2009 18:05
forum net tr, i can do it, ben joe, http://us2.php.net/manual/en/function.strtr.php


/*
 * STRTR as in php :  This function returns a copy of str, translating
 * all occurrences of each character in from to the corresponding
 * character in to
 */
String.prototype.strtr = function(from, to)
{
	var s, p, c1, c2, c3;
	if(! this.length || from.length != to.length) return;
	s = this;	
	for(var i=0; i<str.length; i++)
	{
		c1 = str.substr(i,1);
		for(var j=0; j<from.length; j++)
		{
			c2 = from.substr(j,1);
			c3 = to.substr(j,1);
			if(c1 == c2)
			{
				p = new RegExp(c2,'gi');
				s = s.replace(p,c3);
			}
		}
	}
	return s;
}
/*
 * REMOVEACCENTS: This function returns a copy of str, removing
 * all accents in it
 */
function removeaccents(string) {
 return string.strtr(
"�������ÐÝðý",
"SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
full program full oyun http://www.forumnettr.com
full forum http://www.forumnettr.com/forum 
secilmis youtube videolari http://www.youtubevideolari.net youtube videos
online video tr tube http://www.videotrtube.com
firmalar sirketler rehberi http://www.sirketfirmarehberi.com firma
sirket rehberi adres telefon bilgileri