28 #ifndef UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1 29 #define UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1 37 inline void append(char32_t cp, std::string& s)
39 append(uint32_t(cp), std::back_inserter(s));
42 inline std::string utf16to8(
const std::u16string& s)
45 utf16to8(s.begin(), s.end(), std::back_inserter(result));
49 inline std::u16string utf8to16(
const std::string& s)
51 std::u16string result;
52 utf8to16(s.begin(), s.end(), std::back_inserter(result));
56 inline std::string utf32to8(
const std::u32string& s)
59 utf32to8(s.begin(), s.end(), std::back_inserter(result));
63 inline std::u32string utf8to32(
const std::string& s)
65 std::u32string result;
66 utf8to32(s.begin(), s.end(), std::back_inserter(result));
70 inline std::size_t find_invalid(
const std::string& s)
72 std::string::const_iterator invalid = find_invalid(s.begin(), s.end());
73 return (invalid == s.end()) ? std::string::npos : (invalid - s.begin());
76 inline bool is_valid(
const std::string& s)
78 return is_valid(s.begin(), s.end());
81 inline std::string replace_invalid(
const std::string& s, char32_t replacement)
84 replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement);
88 inline std::string replace_invalid(
const std::string& s)
91 replace_invalid(s.begin(), s.end(), std::back_inserter(result));
95 inline bool starts_with_bom(
const std::string& s)
97 return starts_with_bom(s.begin(), s.end());
102 #endif // header guard