tags:

views:

41

answers:

2

Hello!

In my php + javascript project i have to show images and some of then have accents, like ~ ç and ^. My site are not showing these images. I know that there is a function to treat this, but i forgot. Somebody can help me? thank's

A: 
/*  (C)Scripterlative.com
 *  Strips grave, acute, circumflex umlaut and tilde from vowels and Ñ.
 *
 *  Include this script block, then within the tag of each text element to be controlled, insert:
 *
 *  onblur='this.value=stripVowelAccent(this.value)'
 *
 *  GratuityWare
 *  ~~~~~~~~~~~~
 *  You obtained this script probably out of desperation, so if you wish to express your gratitude for our efforts,
 *  please visit: www.scripterlative.com
 *
 */

function stripVowelAccent(str)
{
 var rExps=[
 {re:/[\xC0-\xC6]/g, ch:'A'},
 {re:/[\xE0-\xE6]/g, ch:'a'},
 {re:/[\xC8-\xCB]/g, ch:'E'},
 {re:/[\xE8-\xEB]/g, ch:'e'},
 {re:/[\xCC-\xCF]/g, ch:'I'},
 {re:/[\xEC-\xEF]/g, ch:'i'},
 {re:/[\xD2-\xD6]/g, ch:'O'},
 {re:/[\xF2-\xF6]/g, ch:'o'},
 {re:/[\xD9-\xDC]/g, ch:'U'},
 {re:/[\xF9-\xFC]/g, ch:'u'},
 {re:/[\xD1]/g, ch:'N'},
 {re:/[\xF1]/g, ch:'n'} ];

 for(var i=0, len=rExps.length; i<len; i++)
  str=str.replace(rExps[i].re, rExps[i].ch);

 return str;
}
Jay
+1  A: 

Try running the image URLs through rawurlencode().

Seth
It works....is this function i was trying to remember.Actually i needed to use rawurldecode(), but is almost the same...it´s just try one and after the other one =DThank's
Paulo