@@ -5,7 +5,8 @@ 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" )
8
+ depsjl = joinpath (dirname (@__FILE__ ), " .." , " deps" , " deps.jl" )
9
+ isfile (depsjl) ? include (depsjl) : error (" libiconv not properly installed. Please run\n Pkg.build(\" iconv\" )" )
9
10
10
11
11
12
# # iconv wrappers
@@ -16,13 +17,13 @@ const EILSEQ = 84
16
17
17
18
function iconv_close (cd:: Ptr{Void} )
18
19
if cd != C_NULL
19
- ccall ((:iconv_close , libiconv_path ), Cint, (Ptr{Void},), cd) == 0 ||
20
+ ccall ((:iconv_close , libiconv ), Cint, (Ptr{Void},), cd) == 0 ||
20
21
error (" failed to call iconv_close: error $(errno ()) ($(strerror (errno ())) )" )
21
22
end
22
23
end
23
24
24
25
function iconv_open (tocode, fromcode)
25
- p = ccall ((:iconv_open , libiconv_path ), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
26
+ p = ccall ((:iconv_open , libiconv ), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
26
27
if p != Ptr {Void} (- 1 )
27
28
return p
28
29
elseif errno () == EINVAL
@@ -69,7 +70,7 @@ function iconv!(cd::Ptr{Void}, inbuf::Vector{UInt8}, outbuf::Vector{UInt8},
69
70
inbytesleft_orig = inbytesleft[]
70
71
outbytesleft[] = BUFSIZE
71
72
72
- ret = ccall ((:iconv , libiconv_path ), Csize_t,
73
+ ret = ccall ((:iconv , libiconv ), Csize_t,
73
74
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
74
75
cd, inbufptr, inbytesleft, outbufptr, outbytesleft)
75
76
@@ -101,7 +102,7 @@ function iconv_reset!(s::Union{StringEncoder, StringDecoder})
101
102
102
103
s. outbufptr[] = pointer (s. outbuf)
103
104
s. outbytesleft[] = BUFSIZE
104
- ret = ccall ((:iconv , libiconv_path ), Csize_t,
105
+ ret = ccall ((:iconv , libiconv ), Csize_t,
105
106
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
106
107
s. cd, C_NULL , C_NULL , s. outbufptr, s. outbytesleft)
107
108
0 commit comments