toSJIS

Encodes a unicode string as SJIS.

Note: Badly-formed unicode strings will always fail.

toSJIS
(
T
)
(,
Flag!"IgnoreInvalid" skipInvalidCharacters = Flag!"IgnoreInvalid".no
)
if (
isSomeString!T
)

Parameters

input T

String to encode.

skipInvalidCharacters Flag!"IgnoreInvalid"

Whether to skip characters that don't exist in SJIS or throw an exception.

Examples

assert(toSJIS("Hello.") == SJISString([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2e]));
assert(toSJIS("Hello.") == SJISString([0x82, 0x67, 0x82, 0x85, 0x82, 0x8c, 0x82, 0x8c,  0x82, 0x8f, 0x81, 0x44]));
assert(toSJIS("Hello."d) == SJISString([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2e]));
assert(toSJIS("Hello."d) == SJISString([0x82, 0x67, 0x82, 0x85, 0x82, 0x8c, 0x82, 0x8c,  0x82, 0x8f, 0x81, 0x44]));
assert(toSJIS("Hello."w) == SJISString([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2e]));
assert(toSJIS("Hello."w) == SJISString([0x82, 0x67, 0x82, 0x85, 0x82, 0x8c, 0x82, 0x8c,  0x82, 0x8f, 0x81, 0x44]));

Meta