Mercurial > hg > egg-tcls
changeset 413:b63525aed190
fetch_weather: Unfortunately we have to deal with some UTF-8 brokenness here.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 07 Jan 2017 22:36:34 +0200 |
parents | e0d86ccef873 |
children | d623652df6b5 |
files | fetch_weather.pl |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/fetch_weather.pl Sat Jan 07 22:34:52 2017 +0200 +++ b/fetch_weather.pl Sat Jan 07 22:36:34 2017 +0200 @@ -361,6 +361,14 @@ die("Failed to fetch $uri data.\n") unless ($res->code <= 200 && $res->code <= 201); $meta_str = $res->decoded_content; + + # XXX: This is a hack. For some reason the data does not get utf8 flagged internally. + if (!utf8::is_utf8($meta_str)) + { + printf STDERR "Upgrading meta_str to UTF-8.\n" if (opt_get_int("debug") > 0); + utf8::upgrade($meta_str); + } + $fetch_meta = 1; } else @@ -369,6 +377,8 @@ $meta_str = read_text($meta_file, "utf-8"); } + print STDERR "Is meta_str UTF8? ".(utf8::is_utf8($meta_str) ? "yes" : "NO!")."\n" if (opt_get_int("debug") > 1); + # Parse the data .. my $meta_data = {}; my $json = JSON->new->decode($meta_str);