Skip to content

Commit

Permalink
fix for insertion operators with char16_t/char32_t
Browse files Browse the repository at this point in the history
  • Loading branch information
fktn-k committed Nov 23, 2023
1 parent 56ef03a commit c3e65d2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/fkYAML/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class invalid_encoding : public exception
std::string generate_error_message(const char* msg, std::array<char16_t, 2> u16)
{
std::stringstream ss;
ss << "invalid_encoding: " << msg << " in=[ 0x" << std::hex << u16[0] << ", 0x" << std::hex << u16[1] << " ]";
ss << "invalid_encoding: " << msg;
// uint16_t is large enough for UTF-16 encoded elements.
ss << " in=[ 0x" << std::hex << uint16_t(u16[0]) << ", 0x" << std::hex << uint16_t(u16[1]) << " ]";
return ss.str();
}

Expand All @@ -117,7 +119,8 @@ class invalid_encoding : public exception
std::string generate_error_message(const char* msg, char32_t u32)
{
std::stringstream ss;
ss << "invalid_encoding: " << msg << " in=0x" << std::hex << u32;
// uint32_t is large enough for UTF-32 encoded elements.
ss << "invalid_encoding: " << msg << " in=0x" << std::hex << uint32_t(u32);
return ss.str();
}
};
Expand Down

0 comments on commit c3e65d2

Please sign in to comment.