81
81
82
82
const BUFSIZE = 100
83
83
84
- type StringEncoder{S<: IO } <: IO
84
+ type StringEncoder{F <: Encoding , T <: Encoding , S<: IO } <: IO
85
85
ostream:: S
86
86
closestream:: Bool
87
87
cd:: Ptr{Void}
@@ -93,7 +93,7 @@ type StringEncoder{S<:IO} <: IO
93
93
outbytesleft:: Ref{Csize_t}
94
94
end
95
95
96
- type StringDecoder{S<: IO } <: IO
96
+ type StringDecoder{F <: Encoding , T <: Encoding , S<: IO } <: IO
97
97
istream:: S
98
98
closestream:: Bool
99
99
cd:: Ptr{Void}
@@ -190,7 +190,8 @@ function StringEncoder(ostream::IO, to::Encoding, from::Encoding=enc"UTF-8")
190
190
cd = iconv_open (ASCIIString (to), ASCIIString (from))
191
191
inbuf = Vector {UInt8} (BUFSIZE)
192
192
outbuf = Vector {UInt8} (BUFSIZE)
193
- s = StringEncoder (ostream, false , cd, inbuf, outbuf,
193
+ s = StringEncoder {typeof(from), typeof(to), typeof(ostream)} (ostream, false ,
194
+ cd, inbuf, outbuf,
194
195
Ref {Ptr{UInt8}} (pointer (inbuf)), Ref {Ptr{UInt8}} (pointer (outbuf)),
195
196
Ref {Csize_t} (0 ), Ref {Csize_t} (BUFSIZE))
196
197
finalizer (s, finalize)
@@ -202,6 +203,12 @@ StringEncoder(ostream::IO, to::AbstractString, from::Encoding=enc"UTF-8") =
202
203
StringEncoder (ostream:: IO , to:: AbstractString , from:: AbstractString ) =
203
204
StringEncoder (ostream, Encoding (to), Encoding (from))
204
205
206
+ function show {F, T, S} (io:: IO , s:: StringEncoder{F, T, S} )
207
+ from = F ()
208
+ to = T ()
209
+ print (io, " StringEncoder{$from , $to }($(s. ostream) )" )
210
+ end
211
+
205
212
# Flush input buffer and convert it into output buffer
206
213
# Returns the number of bytes written to output buffer
207
214
function flush (s:: StringEncoder )
@@ -256,7 +263,8 @@ function StringDecoder(istream::IO, from::Encoding, to::Encoding=enc"UTF-8")
256
263
cd = iconv_open (ASCIIString (to), ASCIIString (from))
257
264
inbuf = Vector {UInt8} (BUFSIZE)
258
265
outbuf = Vector {UInt8} (BUFSIZE)
259
- s = StringDecoder (istream, false , cd, inbuf, outbuf,
266
+ s = StringDecoder {typeof(from), typeof(to), typeof(istream)} (istream, false ,
267
+ cd, inbuf, outbuf,
260
268
Ref {Ptr{UInt8}} (pointer (inbuf)), Ref {Ptr{UInt8}} (pointer (outbuf)),
261
269
Ref {Csize_t} (0 ), Ref {Csize_t} (BUFSIZE), 0 )
262
270
finalizer (s, finalize)
@@ -268,6 +276,12 @@ StringDecoder(istream::IO, from::AbstractString, to::Encoding=enc"UTF-8") =
268
276
StringDecoder (istream:: IO , from:: AbstractString , to:: AbstractString ) =
269
277
StringDecoder (istream, Encoding (from), Encoding (to))
270
278
279
+ function show {F, T, S} (io:: IO , s:: StringDecoder{F, T, S} )
280
+ from = F ()
281
+ to = T ()
282
+ print (io, " StringDecoder{$from , $to }($(s. istream) )" )
283
+ end
284
+
271
285
# Fill input buffer and convert it into output buffer
272
286
# Returns the number of bytes written to output buffer
273
287
function fill_buffer! (s:: StringDecoder )
0 commit comments