iconv.converter
Methods1
function converter.__tostring(self: iconv.converter) -> string
An iconv converter object that converts a string from one encoding to another. Call it as a function to convert a string.
If anything in input_string cannot be converted, there will be an error message and the result string will be unchanged.
Example:
The Unicode code point U+0414 (CYRILLIC CAPITAL LETTER DE) is encoded in UTF-8 as the bytes D0 94. Tarantool uses UTF-8, so use string.hex(string.char(208, 148)) to show the UTF-8 source bytes, then convert the character to UTF-16BE and check the result. The result 0414 shows that iconv conversion works. (Different iconv implementations might use different names, for example UTF-16BE instead of UTF16BE.)
tarantool> string.hex(string.char(208, 148))
--
- d094
...
tarantool> converter = require('iconv').new('UTF16BE', 'UTF8')
--
...
tarantool> utf16_string = converter(string.char(208, 148))
--
...
tarantool> string.hex(utf16_string)
--
- '0414'
...
Returns a string representation of the converter.