Friday, August 24, 2012

escape single quote javascript sanitize clean encode

found here http://stackoverflow.com/questions/2195568/how-do-i-add-slashes-to-a-string-in-javascript after searching for the solution:
str = str.replace(/'/g, "\\'")

But I went ahead and improved the concept with a simple function:

function backslash(str){
var str = encodeURIComponent(str.replace(/'/g, "\\'"));
return str;
}

Named it backslash for simplicity but it actually will clean up # $ % ^ &() and anything else like single quote ' and doble quote (normally worked already)

Now you just plug this in where you need to clear up, i.e.:
var note = window.document.ordrfrm.note.value;
..."&note="+backslash(note);

or simpler
var note = backslash(window.document.ordrfrm.note.value);

Which ever will work even with getElementById and now it's easy to play with the note, user input taken like a champ nothing is screwed up when encounters strange characters (strange for javascript at least)!

hope it helps someone, if you like it or have questions post a comment.

thanks for visiting Edu Boris blog.

Monday, August 13, 2012

how to fix bad avi image or picture of video in windows movie maker

Great solution for windows xp (pro/home) windows movie maker if your trying to import avi divx (even xvid codec didn't seem to work)

from: http://www.moviecodec.com/solutions/movie-maker-codec-for-avi-41952/

1-open movie maker 
2-go to the tools > options menu. 
3-go to the compatibility at the above of window. 
4- at the filter box, check the "ffdshow mpeg-4 video decoder"

5- push “ok” bottom. 
6-import your .avi video and enjoy it. 


(if you do not have this option to check you can download this codec from “http://www.free-codecs.com/FFDShow_download.htm”)

worked great!