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
|
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
when ODIN_OS == .Darwin {
foreign import lib "system:System"
} else {
foreign import lib "system:c"
}
// monetary.h - monetary types
foreign lib {
/*
Places characters into the array pointed to by s as controlled by the string format.
No more than maxsize bytes are placed into the array.
Returns: -1 (setting errno) on failure, the number of bytes added to s otherwise
Example:
posix.setlocale(.ALL, "en_US.UTF-8")
value := 123456.789
buffer: [100]byte
size := posix.strfmon(raw_data(buffer[:]), len(buffer), "%n", value)
if int(size) == -1 {
fmt.panicf("strfmon failure: %s", posix.strerror(posix.errno()))
}
fmt.println(string(buffer[:size]))
Output:
$123,456.79
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html ]]
*/
strfmon :: proc(
s: [^]byte,
maxsize: c.size_t,
format: cstring,
#c_vararg args: ..any,
) -> c.size_t ---
}
|