Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rosidl_runtime_cpp/include/rosidl_runtime_cpp/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,20 @@ inline void value_to_yaml(const std::string & value, std::ostream & out)
inline void value_to_yaml(const std::u16string & value, std::ostream & out)
{
out << "\"";
#if __cplusplus < 201703L
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
#endif
auto flags = out.flags();
size_t index = 0;
while (index < value.size()) {
uint_least16_t character = static_cast<uint_least16_t>(value[index]);
if (!(character & 0xff80)) { // ASCII
#if __cplusplus < 201703L
std::string character_as_string = convert.to_bytes(character);
out << std::hex << character_as_string.c_str();
#else
out << static_cast<char>(character);
#endif
} else if (!(character & 0xff00)) { // only 1 byte set
out << "\\x" << std::hex << std::setw(2) << std::setfill('0') << \
character;
Expand Down