You are here: PSPad forum > English discussion forum > Re: JSON pretty printer stripping unicode

Re: JSON pretty printer stripping unicode

#1 JSON pretty printer stripping unicode

Posted by: Cary | Date: 2014-03-03 18:29 | IP: IP Logged

I recently starting using the plugin to reformat/pretty-print JSON. It works great, except that I find that it is messing with some unicode characters. For example, if I have a ī (\u012b) it comes out a regular i (\u0069) afterwards.

I have been able to workaround this by changing the script to insert the hex numbers (e.g. "\u012b") in place of the original character whenever the character is > 0xFF, or outside the standard ASCII range. However, I'm puzzled as to why it isn't being preserved correctly, when all the script is doing is reading it in and writing it out.

It is obviously reading the character correctly, or my workaround would fail. So the problem has to be when it writes the character back out.

PSPad is displaying the code page as UTF-8 on the status line for the file I am reformatting.

Thanks for any ideas,
Cary

I should clarify that I got the plugin from
stringoftheseus.com
I didn't post this to the bugs forum, since it is not a plugin from this site. Maybe it is a bug in PSPad, though?

Edited 1 time(s). Last edit at 2014-03-03 18:49 by Cary.

Options: Reply | Quote | Up ^


#2 Re: JSON pretty printer stripping unicode

Posted by: myf | Date: 2014-03-04 16:27 | IP: IP Logged

I'm affraid it IS PSPad problem.

Having simple test script placed in \PSPad\Script\JScript which just gets selected (all) text and puts it back into editor shows that there is some unicode problem.

Behaviour shown below in scripts source is from latest dev PSPad build on Win7 64, Czech locale.


/*
- duplicate test line
- select it
- invoke this script
Test line:
---
äāăąćĉċčďđëēĕėęěĝğġģhĥħĩīĭįıijjĵķĸĺļľŀłńņňʼnŋöōŏőœŕŗřśŝşšţťŧüũūŭůűųŵŷÿźżžſ
---
ā ĉċ ēĕė ĝğġģhĥħĩīĭįıijjĵķĸ ļ ŀ ņ ʼnŋ ōŏ œ ŗ ŝ ŧ ũūŭ ųŵŷÿ ſ
a cc eee gggghhhiiiii?jjk? l ? n ?? oo o r s t uuu uwyy ?
^ Differences observed

*/

var module_name = "TEST text";
var module_ver = "0.1";

function gotest()
{
var editor = newEditor();
editor.assignActiveEditor();

if(editor.selText().length > 0)
{ editor.selText(editor.selText());
}
else
{ editor.Text(editor.Text());
}

}

function Init() {
addMenuItem( "test", "", "gotest", "CTRL+ALT+SHIFT+K");
}

Options: Reply | Quote | Up ^


#3 Re: JSON pretty printer stripping unicode

Posted by: Cary | Date: 2014-03-06 22:45 | IP: IP Logged

Thanks for verifying this, I've reported it as a bug in the bug forum.

Options: Reply | Quote | Up ^






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