[sword-devel] python3 , StrongsGreek and unicodeDecodeError
Troy A. Griffitts
scribe at crosswire.org
Sun Jun 16 15:14:30 EDT 2019
Hi Pierre,
I had similar problems with our Java bindings. Java was unforgiving
with invalid UTF-8 characters, as well. Ultimately we should fix any
invalid UTF-8 characters in our modules and encode them correctly, but
my solution was, in the bindings code, to call:
assureValidUTF8()
before returning results to Java. This call is available from SWORD's
utilstr.h
Hope this helps a bit,
Troy
On 6/16/19 12:02 PM, pierre amadio wrote:
> Hi there !
>
> Playing with the python3 Sword module I hit a problem that I did not
> have with python2 when dealing with Strongs definition such as G1140
> (daimonion). It looks like the 'æ' character is causing problem.
>
> This example works with python2, but generate an error when ran wiht python3:
>
> ##########
> import Sword
> library = Sword.SWMgr()
> target=library.getModule("StrongsGreek")
> vk=Sword.SWKey("1140")
> target.setKey(vk)
> strongEntry=target.renderText().getRawData()
> ###########
>
> File "/usr/local/sword/python3/lib64/python3.4/site-packages/Sword.py",
> line 128, in getRawData
> def getRawData(self): return _Sword.SWBuf_getRawData(self)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position
> 73: invalid continuation byte
>
> Anyone knows how to be able to catch the content of this entry in a
> python variable ?
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
More information about the sword-devel
mailing list