Skip to content

Instantly share code, notes, and snippets.

@dimawebmaker
Created February 11, 2017 13:53
Show Gist options
  • Save dimawebmaker/d735472df1c86f5dbbd870bfeadc69c4 to your computer and use it in GitHub Desktop.
Save dimawebmaker/d735472df1c86f5dbbd870bfeadc69c4 to your computer and use it in GitHub Desktop.
JS clear string function
//in: 123�������������������������
//out: 123
function cleanString(input) {
var output = "";
for (var i=0; i<input.length; i++) {
if (input.charCodeAt(i) <= 127) {
output += input.charAt(i);
}
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment