encodeCharNoGC

@nogc version of std.utf.encode() for char[].

The caller must handle ASCII (< 0x80) characters manually; this is asserted to force code using this function to be efficient.

encodeCharNoGC
@safe pure nothrow @nogc
(
Flag!"validated" validated
)
(
ref char[4] buf
,
dchar c
)

Parameters

validated

If true, asssume c is a valid, non-surrogate UTF-32 code point and don't generate any error-checking code. If validated is true, c must be a valid character, otherwise undefined behavior will occur. Also affects the return type.

buf
Type: char[4]

Buffer to write the encoded result to.

c
Type: dchar

Character to encode.

Return Value

Type: auto

If validated is true, number of bytes the encoded character takes up in buf. Otherwise a struct with a 'bytes' member specifying the number of bytes of the endocded character, and a 'string errorMessage' member that is null if there was no error and otherwise stores the error message.

Meta