Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- ASCII Device Control Characters: https://www.w3docs.com/learn-html/html-ascii.html -->
- <!-- Remove Device Control Characters:
- https://stackoverflow.com/questions/26741455/how-to-remove-control-characters-from-string
- https://stackoverflow.com/questions/21284228/removing-control-characters-from-a-utf-8-string-in-php
- -->
- <div id='broken'>test</div>
- <div id='fixed'></div>
- <script>
- var textareaValue = document.getElementById('broken').innerHTML;
- var fixedText = textareaValue.replace(/[\x00-\x1F\x7F-\x9F]/u, "");
- document.getElementById('fixed').innerHTML = fixedText;
- alert(textareaValue + ' : ' + textareaValue.length);
- alert(fixedText + ' : ' + fixedText.length);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement