encodeFromUTF32

Gets encoded Amalthea ASCII based string from dstring (UTF-32).

AsciiBasedString
encodeFromUTF32
(
AsciiBasedString
)
(
dstring s
,
bool safe = false
)
if (
is(AsciiBasedString == KOI8RString) ||
is(AsciiBasedString == KOI8UString)
)

Parameters

s dstring

The UTF32-string for transcoding.

safe bool

If false, the input has to be valid to avoid mistakes, if true, inappropriate characters will be replaced with '?'.

Examples

dstring russianText = "Привет, мир!"d;
KOI8RString koi8rText = encodeFromUTF32!KOI8RString(russianText);
ubyte[] expected = [
    0xf0, 0xd2, 0xc9, 0xd7, 0xc5, 0xd4, 0x2c, 0x20, 0xcd, 0xc9, 0xd2, 0x21
];
assert(cast(ubyte[])koi8rText == expected);

Meta