POSIX iconv binding for Lua.
Converts strings from one codeset to another. For more information, see the original Lua-iconv documentation.
For implementation-specific details of each function, see the corresponding z/OS C runtime library functions.
|iconv (converter, string)||Converts a string from one codeset to another.|
|new (to, from)||Create a conversion descriptor that you can then use with the
|open (to, from)||A synonym for the new function.|
- iconv (converter, string)
Converts a string from one codeset to another.
This function calls the C runtime library function
A conversion descriptor created previously by the
- string string The string that you want to convert.
Two arguments: the converted string and an error code.
The error code has one of the following values:
Error code Description
No error. Conversion was successful.
Failed to allocate enough memory in the conversion process.
An invalid character was found in the input sequence.
An incomplete character was found in the input sequence.
Trying to use an already-finalized converter. This usually means that the user was tweaking the garbage collector private methods.
There was an unknown error.
-- Assumes that you have created a conversion descriptor named converter local before = "Transliterate me" local after = converter:iconv(before)
- converter A conversion descriptor created previously by the
- new (to, from)
Create a conversion descriptor that you can then use with the
iconvfunction to convert a string from one codeset to another.
For a list of supported codesets, see the IBM documentation.
A string that specifies the codeset that you want to convert from.
To enable character transliteration, append the string "//TRANSLIT" to the value of this parameter.
To ignore invalid characters in the input string to the
iconvfunction, append the string "//IGNORE" to the value of this parameter.
- from string A string that specifies the codeset that you want to convert to.
A conversion descriptor that describes a conversion between two codesets,
local iconv = require("iconv") -- Specify codesets local from = "IBM-1047" local to = "ISO8859-1" -- Create conversion descriptor with transliteration option local converter = iconv.new(to .. "//TRANSLIT", from)
- to string A string that specifies the codeset that you want to convert from.
- open (to, from)
- A synonym for the new function.