Array of characters (string, dstring, KOI8RString, ubyte[], etc.).
The start encoding of the transmitted sequence.
The destination encoding for the returned value.
string text = "Привет, мир!"; ubyte[] koi8rText = encodeText(text, "utf-8", "koi8-r"); ubyte[] expected = [ 0xf0, 0xd2, 0xc9, 0xd7, 0xc5, 0xd4, 0x2c, 0x20, 0xcd, 0xc9, 0xd2, 0x21 ]; assert(koi8rText == expected); text = "你好,世界!"; bool error = false; try { koi8rText = encodeText(text, "utf-8", "koi8-r"); } catch (EncodingException e) { error = true; } assert(error);
The function tries to encode text sequence to new encoding. The convertation is based on libiconv. The list is available with 'iconv --list'.
Homepage of libiconv: $(EXT_LINK https://www.gnu.org/software/libiconv/)