#include "cow_string.h" #include #include #include constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes template static void WriteString(IOutputStream& o, const TCharType* w, size_t n) { const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8 TTempBuf buffer(buflen + 1); size_t written = 0; WideToUTF8(w, n, buffer.Data(), written); o.Write(buffer.Data(), written); } template <> void Out(IOutputStream& o, const TCowString& p) { o.Write(p.data(), p.size()); } template <> void Out(IOutputStream& o, const TUtf16CowString& w) { WriteString(o, w.c_str(), w.size()); } template <> void Out(IOutputStream& o, const TUtf32CowString& w) { WriteString(o, w.c_str(), w.size()); } template <> void Out>(IOutputStream& o, const TBasicCharRef& c) { o << static_cast(c); } template <> void Out>(IOutputStream& o, const TBasicCharRef& c) { o << static_cast(c); } template <> void Out>(IOutputStream& o, const TBasicCharRef& c) { o << static_cast(c); }