Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* call with file to be cleaned
- write result into file with postfix ".cleaned"
- */
- var fs = require('fs');
- var system = require('system');
- var text = fs.read(system.args[1]);
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
- if (cx.test(text)) {
- text = text.replace(cx, function(a) {
- return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- });
- }
- fs.write(system.args[0] + '.cleaned', text);
Add Comment
Please, Sign In to add comment