Ah, that's brilliant, thanks Tom

Cheers
Colin

On Sun, 21 Jun 2020, 06:29 Tom Keffer, <[email protected]> wrote:

> It looks like you sorted this problem out yourself, but I thought I'd
> explain why your code was not working.
>
> Under Python 3, all strings are unicode. So, the line
>
> weewx.units.default_unit_label_dict['microgramm_per_meter_cubic']  = '
> \xce\xbcg/m\xc2\xb3'
>
>
> creates a unicode string with code points 32. 206, 188, 103, etc., which
> corresponds to characters 'μg/m³'. The key here is that your code
> is specifying *code points,* not UTF encodings.
>
> If you want to use UTF encodings, then you must decode them into unicode.
> So, it becomes:
>
> weewx.units.default_unit_label_dict['microgramm_per_meter_cubic']  = b'
> \xce\xbcg/m\xc2\xb3'.decode()
>
>
> The right hand side is now a *byte string*, which gets decoded into
> unicode.
>
> -tk
>
>
> On Wed, Jun 17, 2020 at 8:00 PM Colin Larsen <[email protected]>
> wrote:
>
>> Hi all
>>
>> As part of my installation I have FilePile grabbing some air quality
>> data. To get the proper unit formatting for micrograms per cubic meter I
>> use the units line below -
>>
>> weewx.units.default_unit_label_dict[*'microgramm_per_meter_cubic'*]  = *'
>> \xce\xbcg/m\xc2\xb3'*
>>
>> which was working fine until (I think) the update to either Weewx 4.0 or
>> Python 3. The output now looks like this ......
>>
>> CO2 level is 4904 ppm, AQM2.5 is 2.4 μg/m³, AQM10.0 is 2.8 μg/m³, Air
>> Quality Index is 10
>>
>> Any help appreciated
>>
>> Colin
>>
>> --
>> 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/CACjxfUubdgLPY1BaHv3Qe2p%3DkPteM4Ux76azcUpVLfDET117mA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/weewx-user/CACjxfUubdgLPY1BaHv3Qe2p%3DkPteM4Ux76azcUpVLfDET117mA%40mail.gmail.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/CAPq0zEAHn9p%3DkBfP3UWF2Ue9Jp9QCb8DuZVV89veAJ4onzxrFQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/weewx-user/CAPq0zEAHn9p%3DkBfP3UWF2Ue9Jp9QCb8DuZVV89veAJ4onzxrFQ%40mail.gmail.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/CACjxfUuLFw%2Bm4rCEPO3OgunZf3C-mxQrhvXjYs0QcsoFO3DBZg%40mail.gmail.com.

Reply via email to