utf 8 - Javascript: how to convert text copied into textarea from any encoding to UTF-8? -


i have simple html+js page <textarea>.
user supposed paste text inside it, , page use pasted text parameter remote service url expects utf-8.

my current code this:

<body>   <textarea id="editor"></textarea> </body> <script>   var content = document.getelementbyid('editor').innerhtml;   content = striptags(content);   content = decodehtml(content);   content = encodeuricomponent(content);   var url = remoteservicebaseurl + content;   window.open(url, '_blank');    function striptags(input) {     return input.replace(/<(.|\n)*?>/g, '');   }    function decodehtml(html) {     var txt = document.createelement("textarea");     txt.innerhtml = html;     return txt.value;   } <script> 

but has trouble - example - %0c (form-feed) character found in windows-1252 texts: when calling url thrown error urierror: malformed uri sequence.

so question is: how convert text utf-8, indipendently source encoding, javascript?


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -