Display of fahrenheit units doesn't use degree symbol (º)
Aariq opened this issue · 3 comments
Aariq commented
Units for celsius display as ºC
but units for degrees fahrenheit don't use the degree symbol. It would be nice if fahrenheit used the degree symbol also.
library(units)
#> udunits database from /usr/local/share/udunits/udunits2.xml
#both display as ºC
set_units(10, celsius)
#> 10 [°C]
set_units(10, "degC")
#> 10 [°C]
#neither display as ºF
set_units(10, fahrenheit)
#> 10 [fahrenheit]
set_units(10, "degF")
#> 10 [degF]
Created on 2023-01-30 with reprex v2.0.2
Enchufa2 commented
We don't do anything special for either of them. By default, we ask udunits2 for the symbol here, and then fall back to using the name. The thing is...
units:::ud_get_symbol("degC")
#> [1] "°C"
units:::ud_get_symbol("degF")
#> character(0)
udunits2 doesn't return any symbol for Fahrenheit. Not sure why, but this should be fixed upstream.
As a workaround, this works:
units::set_units(10, "°F")
#> 10 [°F]
Aariq commented
Ah, thanks. I had tried this with "ºF" (which is option + 0 on a macOS), but apparently that's not the same character!
> utf8ToInt("º")
[1] 186
> utf8ToInt("°")
[1] 176
Enchufa2 commented
Reported upstream: Unidata/UDUNITS-2#115