Your best bet is to save your python script as utf8, then place a "u"
before the replacement string, identifying the string as Unicode. The new
version handles this sensibly, and if the document is Unicode, uses
Unicode, otherwise it attempts to convert it to ANSI. You might need an
encoding comment on the top of your script:
When I saved this as ANSI and ran it on itself it worked fine: the last line changed to #XäXüXö
When I converted this as UTF-8 and ran it on itself, the last line changed to #XXX
I tried u"XäXüXö" but this didn't help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can, of course, use the old version with pyreplace() but I was looking forward to the increased speed. (My texts sometimes have 300K lines).
Even so, your plugin makes Notepad++ into a wonderful tool
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I am having exactly the same problem, I wanted to clean some of the characters changing the three dots for the character "…" (it looks the same, but it ain't) and put some nice — instead of hyphen (again, very close, but not). I tried everything I saw on the web, but nothing worked when I called the script.
Basically I am trying:
editor.rereplace(u"-", u"—")
Thanks for the answers, Python Script is a great tool :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are right, yes!! :)
I downloaded the plugin yesterday through the Plugin Manager and it was stil the 1.6 version. And now works fine with your example of Hebrew. Thanks again!
Grüße
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I really love the Python plugin for Notepad++ for complex work on large Hebrew texts.
But I'm having problems with Unicode and the new version.
For example, the old version works fine with editor.pymlreplace("cafe", "café")
But in the new version I tried editor.rereplace("cafe", "café") and got: cafe => caf
Do I need to do something complicated with .decode('utf8') or is there a simple fix?
Your best bet is to save your python script as utf8, then place a "u"
before the replacement string, identifying the string as Unicode. The new
version handles this sensibly, and if the document is Unicode, uses
Unicode, otherwise it attempts to convert it to ANSI. You might need an
encoding comment on the top of your script:
See the replace tests for an example -
https://github.com/davegb3/PythonScript/blob/master/PythonScript/python_tests/tests/ReplaceUTF8TestCase.py
Cheers
Dave
I don't think I've got it.
I wrote a file (test.py) and saved it as a Notepad++ plugin script,
then restarted Notepad++ so I could edit it and run it.
The file consisted of:
**
**
When I saved this as ANSI and ran it on itself it worked fine: the last line changed to #XäXüXö
When I converted this as UTF-8 and ran it on itself, the last line changed to #XXX
I tried u"XäXüXö" but this didn't help.
BTW, the reason I need it in UTF-8 is that I'm aiming for things like:
**
**
I can, of course, use the old version with pyreplace() but I was looking forward to the increased speed. (My texts sometimes have 300K lines).
Even so, your plugin makes Notepad++ into a wonderful tool
That should work with a Unicode string (the u before the literal). I'm not
in front of a PC at the moment, but I'll check it and post an example.
Cheers
Dave
Hi, I am having exactly the same problem, I wanted to clean some of the characters changing the three dots for the character "…" (it looks the same, but it ain't) and put some nice — instead of hyphen (again, very close, but not). I tried everything I saw on the web, but nothing worked when I called the script.
Basically I am trying:
editor.rereplace(u"-", u"—")
Thanks for the answers, Python Script is a great tool :)
What version are you using - this was fixed in 1.0.7.
You are right, yes!! :)
I downloaded the plugin yesterday through the Plugin Manager and it was stil the 1.6 version. And now works fine with your example of Hebrew. Thanks again!
Grüße
Ok, I can reproduce it and see the error in the code. I'll get a fix out as soon as possible.
Ok, fixed.
Plan is to fix the another issue with startup.py, then release a new version.
Many thanks for reporting this.
Cheers,
Dave.
Thank you so much for putting so much time into this excellent software