Files
kumomta/docs/reference/kumo.encode/charset_encode.md
T
Wez Furlong 8cb8b3fa7e new: kumo.encode.charset_decode/kumo.encode.charset_encode
These are more immediately useful to me for writing tests, but are
generally useful when you have a policy that might need to to deal
with legacy encoding schemes more directly.
2026-03-28 07:20:34 +00:00

21 lines
828 B
Markdown

# kumo.encode.charset_encode
```lua
kumo.encode.charset_encode(CHARSET, UTF8_INPUT, OPT_IGNORE_ERRORS)
```
{{since('dev')}}
Given an the input string `UTF8_INPUT`, which must be a UTF8 string, encodes it
into the named `CHARSET`, which must be one of the charsets supported by the
converter (the most common latin, japanese, chinese, korean and cyrillic code
pages are supported).
If `OPT_IGNORE_ERRORS` is set to `false`, any errors representing the input
string as the requested charset will cause a lua error to be propagated.
Setting `OPT_IGNORE_ERRORS` to `true`, or omitting `OPT_IGNORE_ERRORS`, will
cause the result to be potentially a partial encoding of the input.
The return value will be a byte string which, barring any encoding errors, will
be the representation of the input string in the requested charset.