Environment:
- OS: Fedora Linux with en_GB.UTF-8 locale
- R version: 4.5
- climate version: latest from GitHub (1.3.0)
Problem:
When running hydro_imgw_daily() on a system with a non-Polish locale, the function fails with a cryptic error (subscript out of bounds or Internal error in alloccol) with no indication that encoding is the cause. The format description file downloaded from IMGW (CODZ_publiczne_format.txt) is encoded in Windows-1250, which cannot be parsed correctly on systems using UTF-8 locale.
A check_locale function looks to be employed to catch such error. The function, however, only checks for two specific locales (C.UTF-8 and en_US.iso885915). Any other non-Polish locale such as en_GB.UTF-8 passes the check silently and the function proceeds as if everything is fine, despite the encoding issue still being present. As far as I understand, this issue is most likely present also in other functions such as meteo_imgw etc.
Workaround:
Simple workaround for users encountering this issue would be to temporarily change the encoding
old_enc = getOption("encoding")
options(encoding = "CP1250")
hydro_imgw(...)
options(encoding = old_enc)
Possible Solution:
It might be possible to fix the issue by specifying the encoding while calling readLines as such: readLines(..., encoding = "CP1250")
Alternatively, check_locale() could be updated to warn when the locale does not match Polish patterns rather than maintaining an incomplete blacklist of known bad locale.
Environment:
Problem:
When running
hydro_imgw_daily()on a system with a non-Polish locale, the function fails with a cryptic error (subscript out of bounds or Internal error in alloccol) with no indication that encoding is the cause. The format description file downloaded from IMGW (CODZ_publiczne_format.txt) is encoded in Windows-1250, which cannot be parsed correctly on systems using UTF-8 locale.A
check_localefunction looks to be employed to catch such error. The function, however, only checks for two specific locales (C.UTF-8 and en_US.iso885915). Any other non-Polish locale such as en_GB.UTF-8 passes the check silently and the function proceeds as if everything is fine, despite the encoding issue still being present. As far as I understand, this issue is most likely present also in other functions such asmeteo_imgwetc.Workaround:
Simple workaround for users encountering this issue would be to temporarily change the encoding
Possible Solution:
It might be possible to fix the issue by specifying the encoding while calling
readLinesas such:readLines(..., encoding = "CP1250")Alternatively, check_locale() could be updated to warn when the locale does not match Polish patterns rather than maintaining an incomplete blacklist of known bad locale.