Skip to content

Instantly share code, notes, and snippets.

@juji
Last active August 29, 2015 14:02
Show Gist options
  • Save juji/70dab5c8dc1d5afe0936 to your computer and use it in GitHub Desktop.
Save juji/70dab5c8dc1d5afe0936 to your computer and use it in GitHub Desktop.
var cleanChar = function(str){
var f = [
String.fromCharCode(8220), //“
String.fromCharCode(8221), //”
String.fromCharCode(8216), //‘
String.fromCharCode(8217), //‘
String.fromCharCode(8211), //–
String.fromCharCode(8212), //—
String.fromCharCode(189), //½
String.fromCharCode(188), //¼
String.fromCharCode(190), //¾
String.fromCharCode(169), //©
String.fromCharCode(174), //®
String.fromCharCode(8230) //…
];
var r = ['"','"',"'","'","-","--","1/2","1/4","3/4","(C)","(R)","..."];
for(var i in f) str = str.replace( new RegExp(f[i],"gi"), r[i] );
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment