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
|
#+build linux, darwin, netbsd, openbsd, freebsd
package posix
import "core:c"
when ODIN_OS == .Darwin {
// NOTE: iconv is in a different library
foreign import lib "system:iconv"
} else {
foreign import lib "system:c"
}
// iconv.h - codeset conversion facility
iconv_t :: distinct rawptr
foreign lib {
/*
Convert the sequence of characters from one codeset, in the array specified by inbuf,
into a sequence of corresponding characters in another codeset, in the array specified by outbuf.
Returns: -1 (setting errno) on failure, the number of non-identical conversions performed on success
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv.html ]]
*/
iconv :: proc(
cd: iconv_t,
inbuf: ^[^]byte,
inbytesleft: ^c.size_t,
outbuf: ^[^]byte,
outbyteslen: ^c.size_t,
) -> c.size_t ---
/*
Deallocates the conversion descriptor cd and all other associated resources allocated by iconv_open().
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv_close.html ]]
*/
iconv_close :: proc(cd: iconv_t) -> result ---
/*
Returns a conversion descriptor that describes a conversion from the codeset specified by the
string pointed to by the fromcode argument to the codeset specified by the string pointed to by
the tocode argument.
Returns: -1 (setting errno) on failure, a conversion descriptor on success
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv_open.html ]]
*/
iconv_open :: proc(tocode: cstring, fromcode: cstring) -> iconv_t ---
}
|