blob: 04bcdf1674e533b98b1a659f0d5ea3624e614a74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
---@meta
---
---Utilites for encoding detection and conversion.
---@class encoding
encoding = {}
---@alias encoding.charset
---|>'"ARMSCII-8"'
---| '"BIG5"'
---| '"BIG5-HKSCS"'
---| '"CP866"'
---| '"CP932"'
---| '"EUC-JP"'
---| '"EUC-KR"'
---| '"EUC-TW"'
---| '"GB18030"'
---| '"GB2312"'
---| '"GBK"'
---| '"GEORGIAN-ACADEMY"'
---| '"HZ"'
---| '"IBM850"'
---| '"IBM852"'
---| '"IBM855"'
---| '"IBM857"'
---| '"IBM862"'
---| '"IBM864"'
---| '"ISO-2022-JP"'
---| '"ISO-2022-KR"'
---| '"ISO-8859-1"'
---| '"ISO-8859-2"'
---| '"ISO-8859-3"'
---| '"ISO-8859-4"'
---| '"ISO-8859-5"'
---| '"ISO-8859-6"'
---| '"ISO-8859-7"'
---| '"ISO-8859-8"'
---| '"ISO-8859-8-I"'
---| '"ISO-8859-9"'
---| '"ISO-8859-10"'
---| '"ISO-8859-13"'
---| '"ISO-8859-14"'
---| '"ISO-8859-15"'
---| '"ISO-8859-16"'
---| '"ISO-IR-111"'
---| '"JOHAB"'
---| '"KOI8-R"'
---| '"KOI8-U"'
---| '"SHIFT_JIS"'
---| '"TCVN"'
---| '"TIS-620"'
---| '"UCS-2BE"'
---| '"UCS-2LE"'
---| '"UHC"'
---| '"UTF-16BE"'
---| '"UTF-16LE"'
---| '"UTF-32BE"'
---| '"UTF-32LE"'
---| '"UTF-7"'
---| '"UTF-8"'
---| '"VISCII"'
---| '"WINDOWS-1250"'
---| '"WINDOWS-1251"'
---| '"WINDOWS-1252"'
---| '"WINDOWS-1253"'
---| '"WINDOWS-1254"'
---| '"WINDOWS-1255"'
---| '"WINDOWS-1256"'
---| '"WINDOWS-1257"'
---| '"WINDOWS-1258"'
---
---Try and detect the encoding to best of capabilities for given file given or
---returns nil and error message on failure.
---@param filename string
---@return string | nil charset
---@return string errmsg
function encoding.detect(filename) end
---
---Same as encoding.detect() but for strings.
---@param text string
---@return string | nil charset
---@return string errmsg
function encoding.detect_string(text) end
---@class encoding.convert_options
---@field handle_to_bom boolean @If applicable adds the byte order marks.
---@field handle_from_bom boolean @If applicable strips the byte order marks.
---@field strict boolean @When true fail if errors found.
---
---Converts the given text from one encoding into another.
---@param tocharset encoding.charset
---@param fromcharset encoding.charset
---@param text string
---@param options? encoding.convert_options
---@return string | nil converted_text
---@return string errmsg
function encoding.convert(tocharset, fromcharset, text, options) end
---
---Get the byte order marks for the given charset if applicable.
---@param charset encoding.charset
---@return string bom
function encoding.get_charset_bom(charset) end
---
---Remove the byte order marks from the given text.
---@param text string A string that may contain a byte order marks.
---@param charset? encoding.charset Charset to scan, if nil scan all charsets with bom.
---@return string cleaned_text
function encoding.strip_bom(text, charset) end
|