After I put the following in user.extensions, your little test template
worked for me, using both html entities, and utf-8 encoding.



*import weewx.unitsweewx.units.obs_group_dict['pm2_5_cf_1'] =
'group_concentration'*

I assume you did the same?

The label for the unit microgram_per_meter_cubed is normally defined in
weewx/defaults.py. Did you change this?

Are labels for other observation types, such as pm2_5, getting garbled? Or,
just pm2_f_cf_1?

One thing I'm noticing: your test template is emitting

µg/m³

One thing I'm noticing: the character sequence µ is hex C2 B5,
which is the UTF-8 encoding for the micro character. Except it's being
emitted using HTML entities for C2 and for B5, instead of the actual bytes.
Same with the cubed symbol.

Not sure what to make of that.


On Fri, Aug 25, 2023 at 8:05 PM vince <[email protected]> wrote:

> Doh - delete that last < in the line above before the body of course...
>
> On Friday, August 25, 2023 at 8:04:46 PM UTC-7 vince wrote:
>
>> Did not help.  Is it possible there is something in the nginx
>> configuration 'or' the combination of python3/cheetah in the venv that
>> might be at fault ?   I'm running a v5 beta pip install FWIW.
>>
>> Here's the simplest example I can cook up.
>> Simply try to show the units for something in group_concentration....
>>
>> #errorCatcher Echo
>>
>> <html lang="en">
>> <head>
>>   <title> test page </title>
>>   <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
>>   </head>
>>   <body>
>>       This should look ok ==> $unit.label.pm2_5_cf_1<
>>    </body>
>> </html>
>>
>>
>>
>> On Friday, August 25, 2023 at 6:47:54 PM UTC-7 Tom Keffer wrote:
>>
>>> Your little test page is still being interpreted by Chrome as being
>>> encoded in "windows-1252". Try including a meta tag for the encoding:
>>>
>>> <html lang="en">
>>> <head>
>>>     <title> test page </title>
>>>     <meta charset="UTF-8">
>>> </head>
>>> <body>
>>>
>>> On Fri, Aug 25, 2023 at 6:08 PM vince <[email protected]> wrote:
>>>
>>>> No joy.
>>>>
>>>> Try "test.html" now for a far simpler variant.
>>>> It'll take a few minutes for the rsync to update the public version.
>>>>
>>>> Here's the page source.
>>>>
>>>> <html lang="en">
>>>>   <head>
>>>>   <title> test page </title>
>>>>   </head>
>>>>
>>>>   <body>
>>>>           <table>
>>>>             <tbody>
>>>>               <tr>
>>>>                 <td class="stats_label">AQI (current)</td>
>>>>                 <td class="stats_data">80.5</td>
>>>>               </tr>
>>>>               <tr>
>>>>                 <td class="stats_label">AQI (last hour)</td>
>>>>                 <td class="stats_data">72.25</td>
>>>>               </tr>
>>>>               <tr>
>>>>                 <td class="stats_label">AQI (last day)</td>
>>>>                 <td class="stats_data">76.80139372822299</td>
>>>>               </tr>
>>>>               <tr>
>>>>                 <td class="stats_label">pm2_5_cf_1</td>
>>>>                 <td class="stats_data">25.960
>>>>  &#194;&#181;g/m&#194;&#179;</td>
>>>>               </tr>
>>>>             </tbody>
>>>>           </table>
>>>>    </body>
>>>> </html>
>>>>
>>>>
>>>> On Friday, August 25, 2023 at 5:32:28 PM UTC-7 Tom Keffer wrote:
>>>>
>>>>> The problem is the 'xmlns' declaration in your <html> tag. It is
>>>>> causing metadata to be pulled in, which says that the character set is
>>>>> "windows-1252".
>>>>>
>>>>> Change this
>>>>>
>>>>>
>>>>>
>>>>> *<html xmlns="http://www.w3.org/1999/xhtml
>>>>> <http://www.w3.org/1999/xhtml>">  <head
>>>>> profile="http://www.w3.org/2005/10/profile
>>>>> <http://www.w3.org/2005/10/profile>">*
>>>>>
>>>>> to this
>>>>>
>>>>> *<html lang="en">*
>>>>> *  <head>*
>>>>>
>>>>> and I think your troubles will go away.
>>>>>
>>>>> -tk
>>>>>
>>>>> On Fri, Aug 25, 2023 at 4:29 PM Greg from Oz <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> I am in Australia and https://www.skahan.net/weewx/purpleair.html
>>>>>> works. So the Australian geo block is working OK.
>>>>>> [image: Screenshot from 2023-08-26 09-25-36.png]
>>>>>>
>>>>>> On Saturday, 26 August 2023 at 09:10:00 UTC+10 Tom Keffer wrote:
>>>>>>
>>>>>>> Both the template and the skin configuration look fine.
>>>>>>>
>>>>>>> Despite being just down the road from you, I am unable to connect to
>>>>>>> your webserver.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Aug 24, 2023 at 5:15 PM vince <[email protected]> wrote:
>>>>>>>
>>>>>>>> URL that rsync uploads to is
>>>>>>>> https://www.skahan.net/weewx/purpleair.html - this will not be
>>>>>>>> available unless you're in US/CA/AU probably due to some geoip blocking
>>>>>>>> that I have set up on the ISP side to try to limit how many bots bang 
>>>>>>>> on
>>>>>>>> the site.
>>>>>>>>
>>>>>>>> Same thing happens on chrome on mac os and iphone as well as Safari
>>>>>>>> on mac os.   The weewx host is a current RaspiOS pi4.   Adding the
>>>>>>>> encoding=utf_8 line didn't help, unfortunately.  The encoding was
>>>>>>>> previously set to html_entities in skin.conf
>>>>>>>>
>>>>>>>> I've attached the .tmpl file and skin.conf for the skin in case
>>>>>>>> there are obvious errors therein.  FWIW the skin is kinda ancient so 
>>>>>>>> it's
>>>>>>>> possible I missed adding something along the way.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thursday, August 24, 2023 at 3:58:44 PM UTC-7 Tom Keffer wrote:
>>>>>>>>
>>>>>>>>> Internal to WeeWX, the label microgram_per_meter_cubed is
>>>>>>>>> encoded in Unicode. To be included in a template, it has to be 
>>>>>>>>> converted to
>>>>>>>>> an appropriate byte string using an encoding. By default, the Seasons
>>>>>>>>> templates use html entities to do this encoding. The results will be 
>>>>>>>>> in
>>>>>>>>> simple ASCII.
>>>>>>>>>
>>>>>>>>> Note: this is *separate* from the encoding used by the templates
>>>>>>>>> themselves, which is generally UTF-8. This is what you're setting 
>>>>>>>>> with the
>>>>>>>>> #encoding directive. This is useful if one were to include UTF-8 
>>>>>>>>> characters *directly
>>>>>>>>> in the templates themselves*. But, that's not what's happening
>>>>>>>>> here.
>>>>>>>>>
>>>>>>>>> The html entity encoding for the cube symbol is either "&sup3;",
>>>>>>>>> or "&#179;". For whatever reason, your Python installation is 
>>>>>>>>> choosing the
>>>>>>>>> latter, which your browser does not seem to be capable of 
>>>>>>>>> interpreting as
>>>>>>>>> the cube symbol. I've seen this happen when the file suffix is 
>>>>>>>>> ".txt", but
>>>>>>>>> yours is ".html" (check!).
>>>>>>>>>
>>>>>>>>> It may be a browser specific thing. What browser are you using?
>>>>>>>>> Perhaps you can point us to the page?
>>>>>>>>>
>>>>>>>>> One thing you can try is another encoding besides html entities.
>>>>>>>>> For example, utf-8.
>>>>>>>>>
>>>>>>>>> *[CheetahGenerator]*
>>>>>>>>> *  encoding=utf_8 *
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Aug 24, 2023 at 3:30 PM vince <[email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Thanks.  No joy.
>>>>>>>>>>
>>>>>>>>>> Added to top of the file under the echo line ala...
>>>>>>>>>>
>>>>>>>>>> ## Copyright 2009-2018 Tom Keffer, Matthew Wall
>>>>>>>>>> ## Distributed under terms of GPLv3.  See LICENSE.txt for your
>>>>>>>>>> rights.
>>>>>>>>>> #errorCatcher Echo
>>>>>>>>>> #encoding UTF-8
>>>>>>>>>>
>>>>>>>>>> #set $periods = $to_list($DisplayOptions.get('periods', ['day',
>>>>>>>>>> 'week', 'month', 'year']))
>>>>>>>>>> #set $plot_groups = $to_list($DisplayOptions.get('plot_groups',
>>>>>>>>>> ['tempdew', 'wind', 'rain']))
>>>>>>>>>>
>>>>>>>>>> ## use this span to determine whether there are any data to
>>>>>>>>>> consider.
>>>>>>>>>> #set $recent=$span($day_delta=30, boundary='midnight')
>>>>>>>>>>
>>>>>>>>>> <!DOCTYPE html>
>>>>>>>>>> <html lang="$lang">
>>>>>>>>>>   <head>
>>>>>>>>>>     <meta charset="UTF-8">
>>>>>>>>>>     <title>$station.location</title>
>>>>>>>>>>     <link rel="icon" type="image/png" href="favicon.ico" />
>>>>>>>>>>     <link rel="stylesheet" type="text/css" href="seasons.css"/>
>>>>>>>>>>     #if $station.station_url
>>>>>>>>>>     <link rel="canonical" href="$station.station_url/$filename" />
>>>>>>>>>>     #end if
>>>>>>>>>>     <script src="seasons.js"></script>
>>>>>>>>>>   </head>
>>>>>>>>>>
>>>>>>>>>>   <body onload="setup();">
>>>>>>>>>>     #include "titlebar.inc"
>>>>>>>>>>
>>>>>>>>>> And appended the AQI line to the footer to make it easier for me
>>>>>>>>>> to find during testing...
>>>>>>>>>>
>>>>>>>>>>     <p class="footnote">
>>>>>>>>>>       $gettext("This station is controlled by <a href='
>>>>>>>>>> https://weewx.com'>WeeWX</a>, an experimental weather software
>>>>>>>>>> system written in Python.")
>>>>>>>>>>       AQI:
>>>>>>>>>> $latest('purpleair_binding').aqi2_5.format(format_string="%.0f")
>>>>>>>>>>  
>>>>>>>>>> ($latest('purpleair_binding').pm2_5_cf_1.format(format_string="%.1f"))
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Result looks like:
>>>>>>>>>>       This station is controlled by WeeWX <https://weewx.com/>,
>>>>>>>>>> an experimental weather software system written in Python. AQI: 64 
>>>>>>>>>> (17.9
>>>>>>>>>> µg/m³)
>>>>>>>>>>
>>>>>>>>>> Output in the .html is:
>>>>>>>>>>    <p class="footnote">
>>>>>>>>>>       This station is controlled by <a 
>>>>>>>>>> href='https://weewx.com'>WeeWX</a>,
>>>>>>>>>> an experimental weather software system written in Python.
>>>>>>>>>> AQI: 64    (17.9 &#194;&#181;g/m&#194;&#179;)
>>>>>>>>>>
>>>>>>>>>> On Thursday, August 24, 2023 at 3:16:01 PM UTC-7 gjr80 wrote:
>>>>>>>>>>
>>>>>>>>>>> I notice the Seasons index.html.tmpl does not have a #encoding
>>>>>>>>>>> directive (though the other Seasons .html.tmpl files do). Have
>>>>>>>>>>> you tried adding a #encoding directive à la:
>>>>>>>>>>>
>>>>>>>>>>> #errorCatcher Echo #encoding UTF-8 <!DOCTYPE html>
>>>>>>>>>>>
>>>>>>>>>>> Gary
>>>>>>>>>>>
>>>>>>>>>>> On Friday, 25 August 2023 at 07:19:12 UTC+10 vince wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Well I can't explain it at all.  I appended the same .tmpl line
>>>>>>>>>>>> at the bottom of index.html.tmpl for the Seasons skin (trusting 
>>>>>>>>>>>> Tom gets
>>>>>>>>>>>> this stuff correctly) and I still see funny encoding in Safari + 
>>>>>>>>>>>> Chrome
>>>>>>>>>>>> (mac) and in Chrome (iphone).   I can only guess it has something 
>>>>>>>>>>>> to do
>>>>>>>>>>>> with the locale or i18n settings on the pi4 that weewx is running 
>>>>>>>>>>>> on, but
>>>>>>>>>>>> I'm just guessing completely at this point.
>>>>>>>>>>>>
>>>>>>>>>>>> On Thursday, August 24, 2023 at 12:54:21 PM UTC-7 Karen K wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Unfortunately the greek my character and the cubic symbol are
>>>>>>>>>>>>> not US-ASCII. So they have the 8th bit set. There are different 
>>>>>>>>>>>>> methods to
>>>>>>>>>>>>> do that. The older one is ISO 8859, where one byte is always one 
>>>>>>>>>>>>> character.
>>>>>>>>>>>>> The newer one is UTF-8 where one character can be 1, 2 or even 
>>>>>>>>>>>>> more bytes.
>>>>>>>>>>>>> So if you have an UTF-8 character, containing of 2 bytes 
>>>>>>>>>>>>> interpreted as ISO
>>>>>>>>>>>>> 8859, you see 2 characters instead of the one you want to see.
>>>>>>>>>>>>>
>>>>>>>>>>>>> So the question is: What does the browser think about the
>>>>>>>>>>>>> character set? And what character set is used for Cheetah?
>>>>>>>>>>>>>
>>>>>>>>>>>>> See the first line of the templates *.html.tmpl. There is a
>>>>>>>>>>>>> line beginning with #encoding followed by the name of a character 
>>>>>>>>>>>>> set. That
>>>>>>>>>>>>> name must match the character set you used to save the file.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Then there may be a line <meta charset="UTF-8" /> (or
>>>>>>>>>>>>> ISO-8859-1 instead of UTF-8).
>>>>>>>>>>>>>
>>>>>>>>>>>>> Then, in skin.conf there may be lines "encoding = ...". What
>>>>>>>>>>>>> do they say?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Make sure, all the encoding directives match your file's
>>>>>>>>>>>>> encoding.
>>>>>>>>>>>>>
>>>>>>>>>>>>> vince schrieb am Donnerstag, 24. August 2023 um 21:29:46 UTC+2:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> I have absolutely no idea what you just said.  Sorry - US
>>>>>>>>>>>>>> ASCII person here :-)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> View source shows
>>>>>>>>>>>>>> AQI: 56    (14.6 &#194;&#181;g/m&#194;&#179;)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> and https://www.w3schools.com/charsets/ref_html_8859.asp
>>>>>>>>>>>>>> matches up (circumflex accent and micro symbol) but I have no 
>>>>>>>>>>>>>> idea what to
>>>>>>>>>>>>>> do about it.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>> 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 [email protected].
>>>>>>>>>> To view this discussion on the web visit
>>>>>>>>>> https://groups.google.com/d/msgid/weewx-user/d39d52c7-3a0d-4a2a-93a8-97fb2f329b7fn%40googlegroups.com
>>>>>>>>>> <https://groups.google.com/d/msgid/weewx-user/d39d52c7-3a0d-4a2a-93a8-97fb2f329b7fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>>> .
>>>>>>>>>>
>>>>>>>>> --
>>>>>>>> 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 [email protected].
>>>>>>>>
>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/weewx-user/34810d7b-e939-4f26-9868-41da36ffc992n%40googlegroups.com
>>>>>>>> <https://groups.google.com/d/msgid/weewx-user/34810d7b-e939-4f26-9868-41da36ffc992n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> --
>>>>>> 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 [email protected].
>>>>>>
>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/weewx-user/36b2cb84-ceb4-4898-9f5b-dd351ebb0461n%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/weewx-user/36b2cb84-ceb4-4898-9f5b-dd351ebb0461n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>> 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 [email protected].
>>>>
>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/weewx-user/c46b679f-4c2a-407e-83f9-57836f539714n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/weewx-user/c46b679f-4c2a-407e-83f9-57836f539714n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/8792f25d-84c0-4e4b-8fd9-9526a13a4a77n%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/8792f25d-84c0-4e4b-8fd9-9526a13a4a77n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAPq0zEAZ-2Js_vYqdT5j1B6CADtRb1jH4nQ-JkZ%2BKjhnyTuC7w%40mail.gmail.com.

Reply via email to