MCPcopy Create free account
hub / github.com/apache/arrow / Utf8ToWcs

Function Utf8ToWcs

cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding.h:72–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71template <typename CHAR_TYPE>
72inline void Utf8ToWcs(const char* utf8_string, size_t length,
73 std::vector<uint8_t>* result) {
74 std::basic_string<CHAR_TYPE> string;
75 if constexpr (sizeof(CHAR_TYPE) == sizeof(char16_t)) {
76 ::utf8::utf8to16(utf8_string, utf8_string + length, std::back_inserter(string));
77 } else {
78 static_assert(sizeof(CHAR_TYPE) == sizeof(char32_t));
79 ::utf8::utf8to32(utf8_string, utf8_string + length, std::back_inserter(string));
80 }
81
82 auto length_in_bytes = static_cast<uint32_t>(string.size() * sizeof(CHAR_TYPE));
83 const uint8_t* data = (uint8_t*)string.data();
84
85 result->reserve(length_in_bytes);
86 result->assign(data, data + length_in_bytes);
87}
88
89inline void Utf8ToWcs(const char* utf8_string, size_t length,
90 std::vector<uint8_t>* result) {

Callers 2

TESTFunction · 0.85

Calls 7

GetSqlWCharSizeFunction · 0.85
DriverExceptionClass · 0.85
to_stringFunction · 0.85
assignMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
reserveMethod · 0.45

Tested by 1

TESTFunction · 0.68