Converts String to a different encoding (UTF8, UTF16). More...
#include <StringConverter.h>
Public Types | |
| enum | StringTermination { NullTerminate , DoNotTerminate } |
| Specifies if to add a null terminator. More... | |
Static Public Member Functions | |
| template<typename T > | |
| static bool | appendEncodingTo (StringEncoding encoding, StringSpan text, T &buffer, StringTermination nullTerminate) |
| Appends to buffer text with requested encoding, optionally null-terminating it too. | |
| static bool | appendEncodingTo (StringEncoding encoding, StringSpan text, IGrowableBuffer &buffer, StringTermination nullTerminate) |
Converts String to a different encoding (UTF8, UTF16).
SC::StringConverter converts strings between different UTF encodings and can add null-terminator if requested. Output is appended to the supplied buffer, including a terminator when requested. On Linux, cross-encoding conversion rejects malformed UTF8/UTF16 before changing the buffer and accepts embedded NUL. It requires only the exact output capacity, including the existing prefix and requested terminator. In that fallback, a source wholly inside the existing logical buffer remains valid across growth; other overlaps are not covered.
Example:
|
inlinestaticnodiscard |
Appends to buffer text with requested encoding, optionally null-terminating it too.
| encoding | The requested destination encoding to convert to |
| text | The StringSpan to be converted |
| buffer | Encoded text will be appended to buffer |
| nullTerminate | Specifies if the StringSpan will need to be null terminated or not |
true if the conversion succeeds