When I try it again, it doesn't replace it, on utf-8 documents, but does so on ANSI ones. (encoding menu on NPP)
I tried doing:
editor.replace('\x92','’')
But it doesn't work either…
How should this be done?
Thanks,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-03-28
Ahh I spoke too soon, in the documentation:
Working with Unicode Text
Python 2.x works with multi-byte strings, as does Scintilla. That means in most cases, you don’t need to do anything special to deal with unicode data, as both sides are talking the same language. However, there are a few things to observe, and occassionaly you’ll need to do something special to achieve what you want to do. One important point is to make sure your script is saved in the same encoding as your target file(s) - this helps unicode strings be interpreted the same way.
If you need to work with the string (for instance chance the case), you need to convert the string to a Python Unicode string. To convert the string append .decode('utf8') to the string. Obviously if your string is in a different format, use the name of the correct encoding.
To put text back to Scintilla (so editor.something()), use .encode(‘utf8’) from a unicode string.
I just changed the encoding on my script to utf-8 (the document was already utf-8) and it worked :O.
Sorry, I didn't search the help file before submitting :D
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
when I try to do :
I get this error in the console:
I added:
to the top of the script,
When I try it again, it doesn't replace it, on utf-8 documents, but does so on ANSI ones. (encoding menu on NPP)
I tried doing:
But it doesn't work either…
How should this be done?
Thanks,
Ahh I spoke too soon, in the documentation:
I just changed the encoding on my script to utf-8 (the document was already utf-8) and it worked :O.
Sorry, I didn't search the help file before submitting :D