| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #include "rtc_base/string_utils.h" |
| 12 |
| 13 | #include "absl/strings/string_view.h" |
| 14 |
| 15 | namespace rtc { |
| 16 |
| 17 | size_t strcpyn(char* buffer, size_t buflen, absl::string_view source) { |
| 18 | if (buflen <= 0) |
| 19 | return 0; |
| 20 |
| 21 | size_t srclen = source.length(); |
| 22 | if (srclen >= buflen) { |
| 23 | srclen = buflen - 1; |
| 24 | } |
| 25 | memcpy(buffer, source.data(), srclen); |
| 26 | buffer[srclen] = 0; |
| 27 | return srclen; |
| 28 | } |
| 29 |
| 30 | std::string ToHex(const int i) { |
| 31 | char buffer[50]; |
| 32 | snprintf(buffer, sizeof(buffer), "%x", i); |
| 33 |
| 34 | return std::string(buffer); |
| 35 | } |
| 36 |
| 37 | } // namespace rtc |
| 38 |