You are here: PSPad forum > English discussion forum > Preserve UTF-8 characters in Javascript Extension
Posted by: YeO | Date: 2016-01-04 10:31 | IP: IP Logged
I have written a Javascript extension to do some cleanup of a text file. However, it does not preserve UTF-8 character and returns '?' where such characters were found. How can I preserve the original character ?
Posted by: vbr | Date: 2016-01-04 11:07 | IP: IP Logged
YeO:I have written a Javascript extension to do some cleanup of a text file. However, it does not preserve UTF-8 character and returns '?' where such characters were found. How can I preserve the original character ?
Hi,
it seems, that you hit a limitation of the current interface of the scripting support in PSPad (it may be enhanced in the planned version of the program).
If I understand correctly, only ANSI characters can be passed between the script code and the GUI of the editor.
In my older script
www.vbr.wz.cz
I used a hackish workaround - the text inserted from the script is newly read from the editor, and if a mismach is found, a supplementary version of the output is generated in a new tab - as html code with non ascii characters coded as unicode number entities.
The text can than be copied from the html preview.
(the code is in the function checkAndSupplResult in the script; be sure to check it works as intended for your needs, if you reuse it).
hth,
vbr
Posted by: YeO | Date: 2016-01-04 12:24 | IP: IP Logged
Thanks for the tip, I hope they fix this issue in future version
Edited 1 time(s). Last edit at 2016-01-04 12:27 by YeO.
Posted by: pspad | Date: 2016-01-04 15:51 | IP: IP Logged
Hello
It won't be as fast fix as you mean, cause it's lot of work to rewrite script module
Posted by: pspad | Date: 2016-01-04 15:52 | IP: IP Logged
YeO:I have written a Javascript extension to do some cleanup of a text file. However, it does not preserve UTF-8 character and returns '?' where such characters were found. How can I preserve the original character ?
Can you be more specific, what your script does? Which manipulation with text do you use?
Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR