Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode file-names not displayed properly in Console #75

Open
Yaron10 opened this issue Jun 7, 2018 · 10 comments
Open

Unicode file-names not displayed properly in Console #75

Yaron10 opened this issue Jun 7, 2018 · 10 comments
Labels
Milestone

Comments

@Yaron10
Copy link

Yaron10 commented Jun 7, 2018

default

As you can see, the entire path is not displayed properly.

Thank you.

@chcg
Copy link
Collaborator

chcg commented Jun 7, 2018

@Yaron10 With which version of the plugin. Could you also paste as short example code which triggers this issue. Is it just the displaying of the error message or is it also not possible to use unicode path.

@Yaron10
Copy link
Author

Yaron10 commented Jun 7, 2018

@chcg,

With which version of the plugin.

v1.1.0.53.

Could you also paste as short example code which triggers this issue.

editor.copy(

Add that line to a file, save it as טסט.py and place it in the scripts folder.
On running it (no problem in this regard), you get the second error shown in the screenshot above: the file-name (טסט.py) is displayed as 84F5~1.py and the path (C:\Program Files\Notepad++\NP\plugins\Config\PythonScript\scripts) is also wrong.

Thank you for looking into it. I appreciate it.

@chcg
Copy link
Collaborator

chcg commented Jun 8, 2018

Unfortunately that is not wrong, but just the short path name (https://msdn.microsoft.com/en-us/library/windows/desktop/aa364989(v=vs.85).aspx) of the file used behind the scenes to access unicode file names/path, because direct input of the unicode name to python api didn't work.

Maybe this could be changed with python 3 (#36), but currently I see no chance to modify that without breaking unicode script filename support from #60.
Also the file link in the console error output is working for me.

@Yaron10
Copy link
Author

Yaron10 commented Jun 8, 2018

Thank you for the explanation.
And thanks again for looking into it.

Maybe this could be changed with python 3 (#36),

So I suppose this issue shouldn't be closed for the time being.

@chcg
Copy link
Collaborator

chcg commented Jun 10, 2018

Let's keep it open, but currently I see no easy fix based on python 2.7. Maybe some deeper inspection of the python sourcecode gives some hints, if UTF-8 filenames are supported, but from the current checks, tests and internet searches it doesn't look promising that this is possible. Therefore the "workaround" with the windows shortname was chosen.

@Yaron10
Copy link
Author

Yaron10 commented Jun 10, 2018

Thanks again. I appreciate your work.

Allow me another related question.

STR:
Open a file named טסט.txt in NPP.
Run (from the console or in a script) notepad.getCurrentFilename().

Result:
default

Is that fixable?


Off-topic but still related:
Can I pass $(FULL_CURRENT_PATH) to a python-script via a command in shortcuts.xml?

Thank you.

@chcg
Copy link
Collaborator

chcg commented Jun 15, 2018

Regarding notepad.getCurrentFilename() and the corresponding result. This seems to be a problem within:

void PythonConsole::writeText(boost::python::object text)
{
assert(mp_consoleDlg);
if (mp_consoleDlg)
{
if (PyUnicode_Check(text.ptr()))
{
boost::python::object utf8String(boost::python::handle<PyObject>(PyUnicode_AsUTF8String(text.ptr())));
std::string textToWrite((const char *)boost::python::extract<const char *>(utf8String), _len(utf8String));
GILRelease release;
mp_consoleDlg->writeText(textToWrite.size(), textToWrite.c_str());
}
else
{
std::string textToWrite((const char *)boost::python::extract<const char *>(text.attr("__str__")()), _len(text));
GILRelease release;
mp_consoleDlg->writeText(textToWrite.size(), textToWrite.c_str());
}
}
}

the input as boost::python:str is UTF8 encoded, but detected as plain string by PyUnicode_Check(). That seems to show it just as encoded version. Need further investigation.

@Yaron10
Copy link
Author

Yaron10 commented Jun 15, 2018

@chcg,

Thank you for looking into the issue and further investigating it.

@chcg chcg added this to the v3.0 milestone Sep 7, 2020
@chcg
Copy link
Collaborator

chcg commented Sep 7, 2020

@Yaron10 I just retested the described issues with the current alpha release https://github.com/bruderstein/PythonScript/releases/tag/v3.0.4 and the issues seems to be fixed with the update to python3 and the changes in the script file loading.

@Yaron10
Copy link
Author

Yaron10 commented Sep 7, 2020

@chcg,

Thank you for your work and for updating here. 👍
I'd rather wait a bit before switching to v3.

@chcg chcg added the Feature label Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants