'ascii' codec can't decode byte 0xc3

231 views
Skip to first unread message

Kike .Asekas

unread,
Sep 23, 2019, 1:46:15 PM9/23/19
to weewx-user
I get this error when I try using spanish characters (ñ,á,é,í,ó,ú). I have #encoding UTF-8 in each page althougnt I get the error in a page only and i have encoding = utf8 in [CheetahGenerator] in skin.conf.

Thomas Keffer

unread,
Sep 23, 2019, 5:02:45 PM9/23/19
to weewx-user
Is there error from a Spanish character in the template, or in skin.conf, or weewx.conf?

Which template?

Please include the log.

-tk

On Mon, Sep 23, 2019 at 10:46 AM Kike .Asekas <enu...@gmail.com> wrote:
I get this error when I try using spanish characters (ñ,á,é,í,ó,ú). I have #encoding UTF-8 in each page althougnt I get the error in a page only and i have encoding = utf8 in [CheetahGenerator] in skin.conf.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/1b478f7f-8c11-41f5-93dd-24bee5f39ff0%40googlegroups.com.

Kike .Asekas

unread,
Sep 24, 2019, 6:54:09 AM9/24/19
to weewx-user
I think is in skin.conf. I remove all spanish characters in the template and the error continues. The template is index.html.tmpl


El lunes, 23 de septiembre de 2019, 23:02:45 (UTC+2), Thomas Keffer escribió:
Is there error from a Spanish character in the template, or in skin.conf, or weewx.conf?

Which template?

Please include the log.

-tk

On Mon, Sep 23, 2019 at 10:46 AM Kike .Asekas <enu...@gmail.com> wrote:
I get this error when I try using spanish characters (ñ,á,é,í,ó,ú). I have #encoding UTF-8 in each page althougnt I get the error in a page only and i have encoding = utf8 in [CheetahGenerator] in skin.conf.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.

Kike .Asekas

unread,
Sep 24, 2019, 7:27:13 AM9/24/19
to weewx-user
I sorry. I don't know where is the problem. I remove all spanish characters from skin.conf, index.html.tmpl and weewx.conf and I remove the template and copy it again from the git repository and the error continues.

Thomas Keffer

unread,
Sep 24, 2019, 7:49:13 AM9/24/19
to weewx-user
It sure would help if you showed us the log...

To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/9b51bca4-22ac-4a2e-8525-2ada1ad7537e%40googlegroups.com.

Kike .Asekas

unread,
Sep 24, 2019, 8:09:13 AM9/24/19
to weewx-user
cheetahgenerator: Generate failed with exception '<type 'exceptions.UnicodeDecodeError'>'
Sep 24 14:05:27 raspberrypi weewx[27767]: cheetahgenerator: **** Ignoring template /etc/weewx/skins/Seasons/index.html.tmpl
Sep 24 14:05:27 raspberrypi weewx[27767]: cheetahgenerator: **** Reason: 'ascii' codec can't decode byte 0xc3 in position 1815: ordinal not in range(128)
Sep 24 14:05:27 raspberrypi weewx[27767]: ****  Traceback (most recent call last):
Sep 24 14:05:27 raspberrypi weewx[27767]: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 332, in generate
Sep 24 14:05:27 raspberrypi weewx[27767]: ****      fd.write(str(compiled_template))
Sep 24 14:05:27 raspberrypi weewx[27767]: ****    File "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1045, in __str__
Sep 24 14:05:27 raspberrypi weewx[27767]: ****      rc = getattr(self, mainMethName)()
Sep 24 14:05:27 raspberrypi weewx[27767]: ****    File "_etc_weewx_skins_Seasons_index_html_tmpl.py", line 216, in respond
Sep 24 14:05:27 raspberrypi weewx[27767]: ****    File "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1685, in _handleCheetahInclude
Sep 24 14:05:27 raspberrypi weewx[27767]: ****      file=file)
Sep 24 14:05:27 raspberrypi weewx[27767]: ****    File "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 772, in compile
Sep 24 14:05:27 raspberrypi weewx[27767]: ****      settings=(compilerSettings or {}))
Sep 24 14:05:27 raspberrypi weewx[27767]: ****    File "/usr/lib/python2.7/dist-packages/Cheetah/Compiler.py", line 1708, in __init__
Sep 24 14:05:27 raspberrypi weewx[27767]: ****      source = unicode(source)
Sep 24 14:05:27 raspberrypi weewx[27767]: ****  UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1815: ordinal not in range(128)

Thomas Keffer

unread,
Sep 24, 2019, 8:47:45 AM9/24/19
to weewx-user
The problem is almost surely in the file /etc/weewx/skins/Seasons/index.html.tmpl. Double check that the top of the file include a #encoding directive:

## Copyright 2009-2018 Tom Keffer, Matthew Wall
## Distributed under terms of GPLv3.  See LICENSE.txt for your rights.
#errorCatcher Echo
##
## Specifying an encoding of UTF-8 is usually safe:
#encoding UTF-8
##
<!DOCTYPE html>

If it does, send me privately your copy of /etc/weewx/skins/Seasons/index.html.tmpl, /etc/weewx/skins/Seasons/skin.conf, and /etc/weewx/weewx.conf and I will see if I can replicate the error. Obfuscate any passwords in weewx.conf.



To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/3d534392-8fea-4c0b-b357-d63126010a1f%40googlegroups.com.

Kike .Asekas

unread,
Sep 24, 2019, 8:52:06 AM9/24/19
to weewx-user
Thank you. The file have #encoding UTF-8. I remove the seasons folder and it copy from github. I change weewx.conf labels to spanish with spanish characters and I don't have errors now. I don't know where was the fault.

Thomas Keffer

unread,
Sep 24, 2019, 9:00:02 AM9/24/19
to weewx-user
Well, if the error went away when you replaced the seasons directory, it must have been in the templates. Your error is typical of templates missing the #encoding directive. 

The other possibility, that the encoding option was wrong in skin.conf, would not cause this error. Instead, the Cheetah engine would have just quietly ignored the spanish characters.

-tk

To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/0e7b929a-9017-4b60-bca1-62f65a265957%40googlegroups.com.

Vetti52

unread,
Feb 5, 2020, 6:47:06 AM2/5/20
to weewx-user
Hi!
As I observed the same problem (playing around with a german translation of latitude and altitude into "Längengrad" and "Höhe", I solved the problem by adding this directive into skins/seasons/about.inc as well.
## about module for weewx skins
## Copyright Tom Keffer, Matthew Wall
## See LICENSE.txt for your rights
#errorCatcher Echo
#encoding UTF-8

I am afraid, that this directive is not inherited to included modules. I presume, that it may be a good idea to add this directive into all of the module files as well, regularly next to the #errorCatcher Echo directive.

Thomas Keffer

unread,
Feb 5, 2020, 10:16:51 AM2/5/20
to weewx-user
Yes, good idea. Done in commit 5d14e61

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Vetti52

unread,
Feb 8, 2020, 12:56:29 PM2/8/20
to weewx-user
Nice to see!
Thanks

After that I am wondering, if there are attempts to prepare a common solution for internationalisation. It was not that easy to find all places, where english expressions had to be replaced. Well, in the Weewx wiki I found at least three solutions, a french standard skin, niculskin and Weewx-Weather34, which provide translations, each at its own way.
I think, it is a hard way to translate once, but harder to maintain a standard Weewx skin for each language, as I just finished the translation into German, similar to the french version. The WeeWx-Weather34 solution is written in PHP, which I am not familiar with. The closest approach to the actual Weewx skin is IMHO that of niculskin, which uses variables for each label and a set of language specific tranlation files. Wouldn't it be another good idea, to modify the actual Weewx.conf and all skin layouts, so that we only need to choose the language in weewx.conf  and the correct labels show up everywhere. If this has been discussed already, I'm sorry, that I have missed it. Otherwise, entering the UTF-8 directive into all files would be a good trigger to complete sophisticated i18n of Weewx.

Thomas Keffer

unread,
Feb 8, 2020, 1:38:56 PM2/8/20
to weewx-user
A translation "lookup" strategy, using something like gettext(), has been discussed from time-to-time.

I actually wrote an implementation of a C++ version of gettext() many years ago for Sun Microsystems, and hated it. You are presented with a long list of text strings like "Temperature", "The temperature is", "The outside temperature is", "The temperature outside is", etc., with no context, and you must supply a translation. Plus, because the text itself must be used as a key, but Cheetah has no mechanism for allowing text to be extracted, you must call a function to identify the text. Your template ends up looking like

<p>$_("The outside temperature is") $current.outTemp</p>

which I do not find appealing, nor easy to teach to a beginner.

In the end, the idea has been rejected as being the worst of two evils.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

p q

unread,
Feb 8, 2020, 2:11:06 PM2/8/20
to weewx...@googlegroups.com
This is starting to look a lot like my day job. :-(




--
Peter Quinn
(415)794-2264

mwall

unread,
Feb 8, 2020, 2:11:52 PM2/8/20
to weewx-user
On Saturday, February 8, 2020 at 12:56:29 PM UTC-5, Vetti52 wrote:
After that I am wondering, if there are attempts to prepare a common solution for internationalisation. It was not that easy to find all places, where english expressions had to be replaced. Well, in the Weewx wiki I found at least three solutions, a french standard skin, niculskin and Weewx-Weather34, which provide translations, each at its own way. 

there is not yet "one true way" for i18n, as you can see from the various skin implementations.  however, l10n is somewhat more standard.

the customization guide describes some sustainable approaches:


some of the fallback/default changes in the weewx 3.9 releases made i18n a bit easier

lately i have been using some i18n libraries in javascript to ensure translations between english, korean, and chinese.  it is tedious.  the approaches tend to follow the old gettext approach, but on the plus side there is better support for tense/plurals/etc using string formatting.

i guess i would generalize to two approaches:

1) if the skin is tiny, then substitute strings (the gettext approach)

2) if the skin is more than a couple of pages, then create a separate directory for each language.  try to consolidate common code if possible.

and of course, if you eliminate words, then you don't have to translate, just localize :)

m

Vetti52

unread,
Feb 9, 2020, 12:50:17 PM2/9/20
to weewx-user
Ok, then 1) is evil, according to Thomas and Peter's opinions. Although the Weewx skin seems to be tiny, but gettext is scary. At least to me.
Choice 2) looks close to, what the french skin (and my own) looks like, which followed the recipe of http://weewx.com/docs/customizing.htm#localization.
Eliminating words may be simple, but, as we deal with a couple of termini technici, I think, it will not work well, to eliminate these words.

So I would prefer 2). However, when looking to the developement of the french skin, you see the disadvantage of this kind of personal solutions, as soon as a new version of Weewx needs adoptions. Therefore, it would be better to build up rules, but not only providing "suggestions for localization". It should also include rules what to do, when updating Weewx. Maybe i18n should be separated from skins into a weewx.i18n library, which serves for labelling all of the present and future skins. Ok, this may become hard work, but IMHO is less evil than gettexting.

Thomas Keffer

unread,
Feb 10, 2020, 8:55:18 AM2/10/20
to weewx-user
Skins have been backwards compatible for years and rarely have a problem with an upgrade. There's no reason why a French skin written for V2.0 back in 2012 wouldn't work with V4.0.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Vetti52

unread,
Feb 11, 2020, 10:28:35 AM2/11/20
to weewx-user
Am Montag, 10. Februar 2020 14:55:18 UTC+1 schrieb Thomas Keffer:
Skins have been backwards compatible for years and rarely have a problem with an upgrade. There's no reason why a French skin written for V2.0 back in 2012 wouldn't work with V4.0.

-tk

 
Well, in github there are two entries for the french skin. One is just a description in french, however containing the same files as the english entry. But there are two files in each:

French translation of the weeWX v3.5.0 default Standard skin
French translation of the weeWX v3.8.2 default Standard skin

I did not try to get into the details of these two versions, but as, to my knowledge, these are the only two examples which realized direct translations, I assumed, that there may be a need to adopt translations at least at certain Weewx version updates.

Anyway, my experience in translating the seasons skin into German told me, that there are a lot of places, where to edit. And I should better have tracked all of my actions - which I didn't. Silly, I know... Any future upgrade (e.g. when a "newSeasons-standard" skin should be appear to be nicer and I would want to translate this also again) will make me mad when tracing back - after several months - to figure out, where all the labels were, and where they are now within the new skin files.
 

Thomas Keffer

unread,
Feb 11, 2020, 11:30:59 AM2/11/20
to weewx-user
I don't know why the author of the French translation chose to have two versions. Perhaps to take advantage of a feature in V3.8?

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Vetti52

unread,
Feb 13, 2020, 2:29:51 PM2/13/20
to weewx-user
Well, I did not get into the development of any of the Weewx versions. However, it would be more comfortable, just to modify the language files only than to get through all of the skin. Therefore I would prefer to separate labelling from internal structure and design. To me, a gettext solution sound overpowered. But you may know better.

Thomas Keffer

unread,
Feb 13, 2020, 3:42:44 PM2/13/20
to weewx...@googlegroups.com
There’s no reason not to try it. A gettext() solution could easily be implemented using search list extensions. 

Now that I think about it, it would be a good v4.1 feature. 

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
--
-tk

Vetti52

unread,
Feb 14, 2020, 11:41:15 AM2/14/20
to weewx-user
Looks good!

If I could contribute, here we go!

Thanks!
Reply all
Reply to author
Forward
0 new messages