Hi !
What do you think about a more complete version of HTMLEncode function ? Would hanld nealy any special character, especially with accents (french).
Tell me about it.
Lionel
function SuperReplace(string,text,by)
{
// Replaces text with by in string
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;
var newstr = string.substring(0,i) + by;
if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);
return newstr;
}
FCKeditor.prototype._HTMLEncode = function( text )
{
if ( typeof( text ) != "string" )
text = text.toString() ;
text = SuperReplace(text,'"',unescape('%22'));
text = SuperReplace(text,'&',unescape('%26'));
text = SuperReplace(text,'<',unescape('%3C'));
text = SuperReplace(text,'>',unescape('%3E'));
text = SuperReplace(text,' ',unescape('%A0'));
text = SuperReplace(text,'',unescape('%A1'));
text = SuperReplace(text,'',unescape('%A2'));
text = SuperReplace(text,'',unescape('%A3'));
text = SuperReplace(text,'',unescape('%A5'));
text = SuperReplace(text,'',unescape('%A6'));
text = SuperReplace(text,'',unescape('%A7'));
text = SuperReplace(text,'',unescape('%A8'));
text = SuperReplace(text,'',unescape('%A9'));
text = SuperReplace(text,'',unescape('%AA'));
text = SuperReplace(text,'',unescape('%AB'));
text = SuperReplace(text,'',unescape('%AC'));
text = SuperReplace(text,'',unescape('%AD'));
text = SuperReplace(text,'',unescape('%AE'));
text = SuperReplace(text,'',unescape('%AF'));
text = SuperReplace(text,'',unescape('%B0'));
text = SuperReplace(text,'',unescape('%B1'));
text = SuperReplace(text,'',unescape('%B2'));
text = SuperReplace(text,'',unescape('%B3'));
text = SuperReplace(text,'',unescape('%B4'));
}
What do you think about a more complete version of HTMLEncode function ? Would hanld nealy any special character, especially with accents (french).
Tell me about it.
Lionel
function SuperReplace(string,text,by)
{
// Replaces text with by in string
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;
var newstr = string.substring(0,i) + by;
if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);
return newstr;
}
FCKeditor.prototype._HTMLEncode = function( text )
{
if ( typeof( text ) != "string" )
text = text.toString() ;
text = SuperReplace(text,'"',unescape('%22'));
text = SuperReplace(text,'&',unescape('%26'));
text = SuperReplace(text,'<',unescape('%3C'));
text = SuperReplace(text,'>',unescape('%3E'));
text = SuperReplace(text,' ',unescape('%A0'));
text = SuperReplace(text,'',unescape('%A1'));
text = SuperReplace(text,'',unescape('%A2'));
text = SuperReplace(text,'',unescape('%A3'));
text = SuperReplace(text,'',unescape('%A5'));
text = SuperReplace(text,'',unescape('%A6'));
text = SuperReplace(text,'',unescape('%A7'));
text = SuperReplace(text,'',unescape('%A8'));
text = SuperReplace(text,'',unescape('%A9'));
text = SuperReplace(text,'',unescape('%AA'));
text = SuperReplace(text,'',unescape('%AB'));
text = SuperReplace(text,'',unescape('%AC'));
text = SuperReplace(text,'',unescape('%AD'));
text = SuperReplace(text,'',unescape('%AE'));
text = SuperReplace(text,'',unescape('%AF'));
text = SuperReplace(text,'',unescape('%B0'));
text = SuperReplace(text,'',unescape('%B1'));
text = SuperReplace(text,'',unescape('%B2'));
text = SuperReplace(text,'',unescape('%B3'));
text = SuperReplace(text,'',unescape('%B4'));
}