1 #include <msp/strings/format.h>
2 #include <msp/strings/utils.h>
8 namespace StringCodec {
10 invalid_character::invalid_character(unichar ch, const string &detail):
11 codec_error(format("U+%04X (%s)", ch, detail))
15 invalid_sequence::invalid_sequence(const string::const_iterator &begin, const string::const_iterator &end, const string &detail):
16 codec_error(format("%s (%s)", format_sequence(begin, end), detail))
19 string invalid_sequence::format_sequence(const string::const_iterator &begin, const string::const_iterator &end)
22 for(auto i=begin; i!=end; ++i)
23 append(result, " ", lexical_cast<string>(static_cast<unsigned char>(*i), Fmt().fill('0').width(2).hex().uppercase()));
27 } // namespace StringCodec