diff --git a/src/string.cc b/src/string.cc index 2ed77156..e4b5c0e2 100644 --- a/src/string.cc +++ b/src/string.cc @@ -151,6 +151,15 @@ InplaceString<24> to_string(float val) return res; } +InplaceString<8> to_string(Codepoint c) +{ + InplaceString<8> res; + char* ptr = res.m_data; + utf8::dump(ptr, c); + res.m_length = (int)(ptr - res.m_data); + return res; +} + bool subsequence_match(StringView str, StringView subseq) { auto it = str.begin(); diff --git a/src/string.hh b/src/string.hh index 424e994c..c853ebe4 100644 --- a/src/string.hh +++ b/src/string.hh @@ -277,6 +277,7 @@ InplaceString<16> to_string(int val); InplaceString<24> to_string(size_t val); InplaceString<24> to_string(Hex val); InplaceString<24> to_string(float val); +InplaceString<8> to_string(Codepoint c); template decltype(to_string(std::declval()))