function escapeVal(data,replaceWith){
//textarea is reference to that object, replaceWith is string that will replace the encoded return
data = escape(data) //encode textarea string's carriage returns
alert(data);
for(i=0; i//loop through string, replacing carriage return encoding with HTML break tag
if(data.indexOf("%0D%0A") > -1){
//alert("1 ");
//Windows encodes returns as \r\n hex
data=data.replace("%0D%0A",replaceWith)
}
else if(data.indexOf("%0A") > -1){
//alert("2 ");
// Unix encodes returns as \n hex
data=data.replace("%0A",replaceWith)
}
else if(data.indexOf("%0D") > -1){
//alert("3 ");
//Macintosh encodes returns as \r hex
data=data.replace("%0D",replaceWith)
} else if(data.indexOf("%20") > -1) {
//replace space
data=data.replace("%20"," ")
}
}
data=unescape(data) //unescape all other encoded characters
alert(data);
return data;
}
Thursday, June 05, 2008
remove CR and LF
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment