Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

translating accented characters

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
Does anyone have any code that will translate accented characters (for example 'Ö') into there nearest non-accented equivalent (Latin-1 character set)?

It's for an e-commerce solution I'm working on, the CC processing system rejects any details that contain non- Latin-1 characterset characters, and I can't change it to anything more suitable.
 
function removeaccents($string) {
return strtr($string, "ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
}

should do the trick --BB
 
Heh, I came up with this:

Code:
function replaceSpecialChars($string)
	{
	return strtr($string, "¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ","                               AAAAAAACEEEEIIIIDNOOOOOxOUUUUYPaaaaaaaaceeeeiiiionooooo ouuuuyb");
	}

But I like your version better :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top