8181
8282const BUFSIZE = 100
8383
84- type StringEncoder{S<: IO } <: IO
84+ type StringEncoder{F <: Encoding , T <: Encoding , S<: IO } <: IO
8585 ostream:: S
8686 closestream:: Bool
8787 cd:: Ptr{Void}
@@ -93,7 +93,7 @@ type StringEncoder{S<:IO} <: IO
9393 outbytesleft:: Ref{Csize_t}
9494end
9595
96- type StringDecoder{S<: IO } <: IO
96+ type StringDecoder{F <: Encoding , T <: Encoding , S<: IO } <: IO
9797 istream:: S
9898 closestream:: Bool
9999 cd:: Ptr{Void}
@@ -190,7 +190,8 @@ function StringEncoder(ostream::IO, to::Encoding, from::Encoding=enc"UTF-8")
190190 cd = iconv_open (ASCIIString (to), ASCIIString (from))
191191 inbuf = Vector {UInt8} (BUFSIZE)
192192 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,
194195 Ref {Ptr{UInt8}} (pointer (inbuf)), Ref {Ptr{UInt8}} (pointer (outbuf)),
195196 Ref {Csize_t} (0 ), Ref {Csize_t} (BUFSIZE))
196197 finalizer (s, finalize)
@@ -202,6 +203,12 @@ StringEncoder(ostream::IO, to::AbstractString, from::Encoding=enc"UTF-8") =
202203StringEncoder (ostream:: IO , to:: AbstractString , from:: AbstractString ) =
203204 StringEncoder (ostream, Encoding (to), Encoding (from))
204205
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+
205212# Flush input buffer and convert it into output buffer
206213# Returns the number of bytes written to output buffer
207214function flush (s:: StringEncoder )
@@ -256,7 +263,8 @@ function StringDecoder(istream::IO, from::Encoding, to::Encoding=enc"UTF-8")
256263 cd = iconv_open (ASCIIString (to), ASCIIString (from))
257264 inbuf = Vector {UInt8} (BUFSIZE)
258265 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,
260268 Ref {Ptr{UInt8}} (pointer (inbuf)), Ref {Ptr{UInt8}} (pointer (outbuf)),
261269 Ref {Csize_t} (0 ), Ref {Csize_t} (BUFSIZE), 0 )
262270 finalizer (s, finalize)
@@ -268,6 +276,12 @@ StringDecoder(istream::IO, from::AbstractString, to::Encoding=enc"UTF-8") =
268276StringDecoder (istream:: IO , from:: AbstractString , to:: AbstractString ) =
269277 StringDecoder (istream, Encoding (from), Encoding (to))
270278
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+
271285# Fill input buffer and convert it into output buffer
272286# Returns the number of bytes written to output buffer
273287function fill_buffer! (s:: StringDecoder )
0 commit comments