Throw an error if UTF-8 encoding is incorrect

This commit is contained in:
John Wiegley 2009-11-07 06:39:14 -05:00
parent 0cf9fbfbf8
commit c8bab6d1c6

View file

@ -512,7 +512,7 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
for (std::size_t i = 0; i < bytes; i++) { for (std::size_t i = 0; i < bytes; i++) {
in.get(c); in.get(c);
if (in.bad() || in.eof()) if (in.bad() || in.eof())
break; throw_(amount_error, _("Invalid UTF-8 encoding for commodity name"));
*_p++ = c; *_p++ = c;
} }
} }
@ -526,7 +526,7 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
if (c == '\\') { if (c == '\\') {
in.get(c); in.get(c);
if (in.eof()) if (in.eof())
break; throw_(amount_error, _("Backslash at end of commodity name"));
} }
*_p++ = c; *_p++ = c;
} }