encoding/charset

Search:
Group by:

This module contains the Charset enum used by encoder and decoder.

Types

Charset = enum
  csUnknown, csUtf8 = "utf-8", csIbm866 = "ibm866", csIso8859_2 = "iso-8859-2",
  csIso8859_3 = "iso-8859-3", csIso8859_4 = "iso-8859-4",
  csIso8859_5 = "iso-8859-5", csIso8859_6 = "iso-8859-6",
  csIso8859_7 = "iso-8859-7", csIso8859_8 = "iso-8859-8",
  csIso8859_8i = "iso-8859-8-i", csIso8859_10 = "iso-8859-10",
  csIso8859_13 = "iso-8859-13", csIso8859_14 = "iso-8859-14",
  csIso8859_15 = "iso-8859-15", csIso8859_16 = "iso-8859-16",
  csKoi8r = "koi8-r", csKoi8u = "koi8-u", csMacintosh = "macintosh",
  csWindows874 = "windows-874", csWindows1250 = "windows-1250",
  csWindows1251 = "windows-1251", csWindows1252 = "windows-1252",
  csWindows1253 = "windows-1253", csWindows1254 = "windows-1254",
  csWindows1255 = "windows-1255", csWindows1256 = "windows-1256",
  csWindows1257 = "windows-1257", csWindows1258 = "windows-1258",
  csXMacCyrillic = "x-mac-cyrillic", csGbk = "gbk", csGb18030 = "gb18030",
  csBig5 = "Big5", csEucJP = "euc-jp", csIso2022JP = "iso-2022-jp",
  csShiftJIS = "shift_jis", csEucKR = "euc-kr", csReplacement = "replacement",
  csUtf16be = "utf-16be", csUtf16le = "utf-16le",
  csXUserDefined = "x-user-defined"

Procs

proc getCharset(s: string): Charset {....raises: [], tags: [], forbids: [].}

Return a Charset from the label s. This function is equivalent to the standard "get an encoding from a string label" algorithm:

https://encoding.spec.whatwg.org/#concept-encoding-get

On failure, csUnknown is returned.

proc getLocaleCharset(s: string): Charset {....raises: [], tags: [], forbids: [].}
Extract a charset from a locale. e.g. returns EUC_JP for the string LC_ALL=ja_JP.EUC_JP.