[liblouis-liblouisxml] SV: Re: SV: Re: Python, please leave my Braille in peace

  • From: Bue Vester-Andersen <bue@xxxxxxxxxxxxxxxxxx>
  • To: <liblouis-liblouisxml@xxxxxxxxxxxxx>
  • Date: Mon, 14 Sep 2015 17:49:04 +0200

Thanks Arend, but I think that would be somewhat of a detour. I already have
the 8 bit output. I just need Python to stop trying to convert it to unicode
or complaining about characters > \x7f.

I am sorry for all this inconvenience. I thought this would be easy for the
Python guros on this list (smile)

Bue


-----Oprindelig meddelelse-----
Fra: liblouis-liblouisxml-bounce@xxxxxxxxxxxxx
[mailto:liblouis-liblouisxml-bounce@xxxxxxxxxxxxx] På vegne af Arend Arends
Sendt: 14. september 2015 17:30
Til: liblouis-liblouisxml@xxxxxxxxxxxxx
Emne: [liblouis-liblouisxml] Re: SV: Re: Python, please leave my Braille in
peace

Maybe you can use unicode.dis for the braille output. It would be easy to
convert that back to 8 bit.

Arend

-----Oorspronkelijk bericht-----
From: Bue Vester-Andersen
Sent: Monday, September 14, 2015 4:34 PM
To: liblouis-liblouisxml@xxxxxxxxxxxxx
Subject: [liblouis-liblouisxml] SV: Re: Python, please leave my Braille in
peace

Hi Michael,

Thanks for the suggestion.
I hope it won't be necesary to write a new encoder from scratch. I don't
really want to map something to something else. I just want to convince
Python that I am dealing with 8-bit ASCII strings, and not have Python try
to remap them to unicode. It seems that in python, everything is either
unicode or 7-bit ASCII.

Bue


-----Oprindelig meddelelse-----
Fra: liblouis-liblouisxml-bounce@xxxxxxxxxxxxx
[mailto:liblouis-liblouisxml-bounce@xxxxxxxxxxxxx] På vegne af Michael
Whapples
Sendt: 14. september 2015 15:34
Til: liblouis-liblouisxml@xxxxxxxxxxxxx
Emne: [liblouis-liblouisxml] Re: Python, please leave my Braille in peace

If I understand correctly, would writing a custom string encoder help.

Here is a question about writing a custom encoder on stackoverflow
http://stackoverflow.com/questions/5819586/how-do-i-write-a-custom-encoding-
in-python-to-clean-up-my-data

Michael Whapples

On 14/09/2015 14:24, Bue Vester-Andersen wrote:

Hi,

Please, I hope someone can help me solve this Python problem:

When handling Danish Braille output from Liblouis, I need to not just
handle
7-bit ASCII, but the full 8-bit range, perhaps except \x00 and \x7f (null
and delete).
Actually, the Danish 8 dot character set is built on cp1252, but with some
additional characters that are not defined in cp1252. So, I need to make
Python think that the Braille output is just some 8-bit ASCII of some code
page or other, and then make it keep its hands off my Braille, so that I
can
output it to a file as it is.

I have tried code like:

return louis.translateString([tableString], inString).decode("cp437")

Then I get the following error:

Traceback (most recent call last):
...
File "c:\python27\lib\encodings\cp437.py", line 15, in decode
return codecs.charmap_decode(input,errors,decoding_table)
UnicodeEncodeError: 'ascii' codec can't encode character u'\x98' in
position
0:
ordinal not in range(128)

Anybody has a good idea?

Bue


For a description of the software, to download it and links to
project pages go to http://liblouis.org

For a description of the software, to download it and links to
project pages go to http://liblouis.org

For a description of the software, to download it and links to
project pages go to http://liblouis.org


For a description of the software, to download it and links to
project pages go to http://liblouis.org

For a description of the software, to download it and links to
project pages go to http://liblouis.org

Other related posts:

  • » [liblouis-liblouisxml] SV: Re: SV: Re: Python, please leave my Braille in peace - Bue Vester-Andersen