diff --git a/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp b/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp index 26d5d1b6..41831dad 100644 --- a/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp +++ b/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp @@ -15,6 +15,7 @@ #include "liveliness_utils.hpp" #include +#include #include #include #include @@ -296,14 +297,11 @@ std::optional keyexpr_to_qos(const std::string & keyexpr) ///============================================================================= std::string zid_to_str(const z_id_t & id) { - std::stringstream ss; - ss << std::hex; - for (std::size_t i = 0; i < sizeof(id.id); i++) { - // By Zenoh convention a z_id_t is a little endian u128. - const std::size_t le_idx = sizeof(id.id) - 1 - i; - ss << static_cast(id.id[le_idx]); + std::ostringstream oss; + for (int i = sizeof(id.id) - 1; i >= 0; i--) { + oss << std::setw(2) << std::setfill('0') << std::hex << static_cast(id.id[i]); } - return ss.str(); + return oss.str(); } ///=============================================================================