Skip to content

Commit

Permalink
[Quirk] Simplify code a bit in hope to make MSVC 'fatal error C1001: …
Browse files Browse the repository at this point in the history
…Internal compiler error' go away
  • Loading branch information
buck-yeh committed Dec 14, 2024
1 parent 3a545d7 commit ddc169c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions include/bux/UnicodeCvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,20 @@ std::string to_utf8(const T *ps, size_t size = 0, T_Encoding codepage = 0)
if (!size)
size = std::char_traits<T>::length(ps);

return to_utf8(C_UnicodeIn(std::string_view{reinterpret_cast<const char*>(ps), size*sizeof(T)}, codepage));
std::string_view view_as_chars{reinterpret_cast<const char*>(ps), size*sizeof(T)};
return to_utf8(C_UnicodeIn(view_as_chars, codepage));
}
template<typename T>
std::string to_utf8(const std::basic_string<T> &s, T_Encoding codepage = 0)
{
return to_utf8(C_UnicodeIn(std::string_view{reinterpret_cast<const char*>(s.data()), s.size()*sizeof(T)}, codepage));
std::string_view view_as_chars{reinterpret_cast<const char*>(s.data()), s.size()*sizeof(T)};
return to_utf8(C_UnicodeIn(view_as_chars, codepage));
}
template<typename T>
std::string to_utf8(std::basic_string_view<T> s, T_Encoding codepage = 0)
{
return to_utf8(C_UnicodeIn(std::string_view{reinterpret_cast<const char*>(s.data()), s.size()*sizeof(T)}, codepage));
std::string_view view_as_chars{reinterpret_cast<const char*>(s.data()), s.size()*sizeof(T)};
return to_utf8(C_UnicodeIn(view_as_chars, codepage));
}

template<typename T>
Expand Down

0 comments on commit ddc169c

Please sign in to comment.