Converts between different character encodings. On UNIX, this uses the iconv library, on Windows the Windows API.
Procs
proc getCurrentEncoding(): string {.
raises: [], tags: [].}- retrieves the current encoding. On Unix, always "UTF-8" is returned. Source Edit
proc open(destEncoding = "UTF-8"; srcEncoding = "CP1252"): EncodingConverter {.
raises: [EncodingError], tags: [].}- opens a converter that can convert from srcEncoding to destEncoding. Raises EIO if it cannot fulfill the request. Source Edit
proc close(c: EncodingConverter) {.
raises: [], tags: [].}- frees the resources the converter c holds. Source Edit
proc convert(c: EncodingConverter; s: string): string {.
raises: [OSError], tags: [].}- Source Edit
proc convert(s: string; destEncoding = "UTF-8"; srcEncoding = "CP1252"): string {.
raises: [EncodingError, OSError], tags: [].}- converts s to destEncoding. It assumed that s is in srcEncoding. This opens a converter, uses it and closes it again and is thus more convienent but also likely less efficient than re-using a converter. Source Edit