StringUtil
Small, locale-independent string helpers. This is a pure-Kotlin port of the portable parts of libtorrent's string_util.cpp and string_util.hpp (plus base64encode from escape_string.cpp).
These deliberately reimplement the C ctype predicates (isalpha, isspace, …) over the ASCII range only, exactly like libtorrent does, so that behaviour is identical on every platform regardless of the C locale. That is why libtorrent wrote its own. Anything in string_util.cpp that depends on sockets, addresses, the global RNG, locale conversion, or raw C memory management (parse_listen_interfaces, print_listen_interfaces, url_random, allocate_string_copy, convert_to_native, is_i2p_url, …) is intentionally not ported here.
Where libtorrent returns std::pair<string_view, string_view> (zero-copy views into the original buffer), the Kotlin equivalents return Pair
Functions
libtorrent base64encode: standard base64 with = padding. Operates on raw bytes (the C++ takes a std::string but treats it as a byte buffer).
Convenience: base64-encode the UTF-8 bytes of s.
libtorrent convert_path_to_posix (escape_string.cpp): replace every \ with /.
libtorrent ensure_trailing_slash (inline in string_util.hpp).
libtorrent is_space: ASCII whitespace. Note this matches the C set ' ' \t \n \r \f \v, and not Kotlin's Char.isWhitespace, which is Unicode-aware.
libtorrent parse_comma_separated_string: split input on commas, trimming leading and trailing ASCII whitespace from each element. Empty elements are kept (the C++ pushes back the possibly-empty substring), matching the outgoing_interfaces-style parsing.
libtorrent split_string_quotes: like splitString, but if the string starts with a double-quote ("), and the separator itself is not ", then separators are ignored until the closing quote. Faithful port of the index-walking in the C++.
libtorrent string_equal_no_case: ASCII case-insensitive equality.
libtorrent strip_string: drop leading and trailing ASCII whitespace, using the full isSpace set (space tab nl cr ff vt).
ASCII-only lower-cased copy of s; locale-independent, unlike String.lowercase.
libtorrent to_string(std::int64_t): decimal text of n with a well-defined, locale-independent result. It handles Long.MIN_VALUE correctly. That magnitude is not representable as a positive signed Long, so the digits are produced via unsigned arithmetic, exactly as the C++ does.
libtorrent trim (escape_string.cpp): strips only " \t\n\r". This is the narrower set the trim helper uses (no form-feed, no vertical-tab), kept distinct from stripString to stay faithful to both call sites.