1 #include <msp/strings/format.h>
7 namespace StringCodec {
9 invalid_character::invalid_character(unichar ch, const string &detail):
10 codec_error(format("U+%04X (%s)", ch, detail))
14 invalid_sequence::invalid_sequence(const string::const_iterator &begin, const string::const_iterator &end, const string &detail):
15 codec_error(format("%s (%s)", format_sequence(begin, end), detail))
18 string invalid_sequence::format_sequence(const string::const_iterator &begin, const string::const_iterator &end)
21 for(string::const_iterator i=begin; i!=end; ++i)
25 result += lexical_cast<string>(static_cast<unsigned char>(*i), Fmt().fill('0').width(2).hex().uppercase());
30 } // namespace StringCodec