FriedrichFroebel / brother_ql_web

A Python-based web service to print labels on Brother QL label printers. Based on brother_ql: https://github.com/pklaus/brother_ql
GNU General Public License v3.0
7 stars 2 forks source link

Fails when ë (e with an umlaut) is present #9

Closed neilzone closed 9 months ago

neilzone commented 9 months ago

When I use label text including ë, the preview does not update, and the label will not print.

I have tried with some different fonts, just in case it is a font issue. I have had the same issue with all fonts.

neilzone commented 9 months ago

And seemingly also a Š - I wonder if it is an issue with all special characters. I'll see if I can come up with a more useful error message.

neilzone commented 9 months ago

Here's the error information:


File "/home/neil/.local/pipx/venvs/brother-ql-web/bin/bottle.py", line 876, in _handle
return route.call(**args)
^^^^^^^^^^^^^^^^^^
File "/home/neil/.local/pipx/venvs/brother-ql-web/bin/bottle.py", line 1759, in wrapper
     rv = callback(*a, **ka)
          ^^^^^^^^^^^^^^^^^^
File "/home/neil/.local/pipx/venvs/brother-ql-web/lib/python3.11/site-packages/brother_ql_web/web.py", line 85, in get_pr>
    parameters = get_label_parameters(bottle.request)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/neil/.local/pipx/venvs/brother-ql-web/lib/python3.11/site-packages/brother_ql_web/web.py", line 56, in get_la>
    d = request.params.decode()  # UTF-8 decoded form data
         ^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/neil/.local/pipx/venvs/brother-ql-web/bin/bottle.py", line 1935, in decode
     copy.append(self._fix(key, enc), self._fix(value, enc))
                                     ^^^^^^^^^^^^^^^^^^^^^
   File "/home/neil/.local/pipx/venvs/brother-ql-web/bin/bottle.py", line 1921, in _fix
     return s.encode('latin1').decode(encoding or self.input_encoding)
           ^^^^^^^^^^^^^^^^^^
 UnicodeEncodeError: 'latin-1' codec can't encode character '\u0160' in position 7: ordinal not in range(256)
FriedrichFroebel commented 9 months ago

Thanks for the report. This seems to be a bottle issue/oddity: https://github.com/bottlepy/bottle/blob/99341ff3791b2e7e705d7373e71937e9018eb081/bottle.py#L2197-L2203

I have just committed a corresponding fix: https://github.com/FriedrichFroebel/brother_ql_web/commit/edf9aa0cef34a11e2eba8c5b6beaebe1e065771c.

neilzone commented 9 months ago

Oh, wow, you are way ahead of me - I was just starting to dig into it, and you've already addressed it!

FriedrichFroebel commented 9 months ago

In this case, this probably has been coincidence as this seemed easy enough to have a look at it after work to at least pinpoint the source, but the fix turned out to be rather straightforward as well.

neilzone commented 9 months ago

(Confirmed working via the git repository version; thank you.)