@@ -5,6 +5,9 @@ import Base: close, eof, flush, read, readall, write
5
5
import Base. Libc: errno, strerror
6
6
export StringEncoder, StringDecoder, encode, decode
7
7
8
+ include (" ../deps/deps.jl" )
9
+
10
+
8
11
# # iconv wrappers
9
12
10
13
const E2BIG = 7
@@ -13,13 +16,13 @@ const EILSEQ = 84
13
16
14
17
function iconv_close (cd:: Ptr{Void} )
15
18
if cd != C_NULL
16
- ccall ((:iconv_close , :libc ), Cint, (Ptr{Void},), cd) == 0 ||
19
+ ccall ((:iconv_close , libiconv_path ), Cint, (Ptr{Void},), cd) == 0 ||
17
20
error (" failed to call iconv_close: error $(errno ()) ($(strerror (errno ())) )" )
18
21
end
19
22
end
20
23
21
24
function iconv_open (tocode, fromcode)
22
- p = ccall ((:iconv_open , :libc ), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
25
+ p = ccall ((:iconv_open , libiconv_path ), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
23
26
if p != Ptr {Void} (- 1 )
24
27
return p
25
28
elseif errno () == EINVAL
@@ -66,7 +69,7 @@ function iconv!(cd::Ptr{Void}, inbuf::Vector{UInt8}, outbuf::Vector{UInt8},
66
69
inbytesleft_orig = inbytesleft[]
67
70
outbytesleft[] = BUFSIZE
68
71
69
- ret = ccall ((:iconv , :libc ), Csize_t,
72
+ ret = ccall ((:iconv , libiconv_path ), Csize_t,
70
73
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
71
74
cd, inbufptr, inbytesleft, outbufptr, outbytesleft)
72
75
@@ -98,7 +101,7 @@ function iconv_reset!(s::Union{StringEncoder, StringDecoder})
98
101
99
102
s. outbufptr[] = pointer (s. outbuf)
100
103
s. outbytesleft[] = BUFSIZE
101
- ret = ccall ((:iconv , :libc ), Csize_t,
104
+ ret = ccall ((:iconv , libiconv_path ), Csize_t,
102
105
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
103
106
s. cd, C_NULL , C_NULL , s. outbufptr, s. outbytesleft)
104
107
0 commit comments