Skip to content

Instantly share code, notes, and snippets.

@dimm999
Created February 11, 2017 13:53
Show Gist options
  • Save dimm999/d735472df1c86f5dbbd870bfeadc69c4 to your computer and use it in GitHub Desktop.
Save dimm999/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