@@ -285,8 +285,24 @@ function read(s::StringDecoder, ::Type{UInt8})
285
285
eof (s) ? throw (EOFError ()) : s. outbuf[s. skip+= 1 ]
286
286
end
287
287
288
- function readall (filename:: AbstractString , encoding:: ASCIIString )
289
- open (s -> readall (StringDecoder (s, encoding)), filename)
288
+
289
+ # # Convenience I/O functions
290
+ if isdefined (Base, :readstring )
291
+ """
292
+ readstring(stream or filename, enc::ASCIIString)
293
+
294
+ Read the entire contents of an I/O stream or a file in encoding `enc` as a string.
295
+ """
296
+ Base. readstring (s:: IO , enc:: ASCIIString ) = readstring (StringDecoder (s, enc))
297
+ Base. readstring (filename:: AbstractString , enc:: ASCIIString ) = open (io-> readstring (io, enc), filename)
298
+ else # Compatibility with Julia 0.4
299
+ """
300
+ readall(stream or filename, enc::ASCIIString)
301
+
302
+ Read the entire contents of an I/O stream or a file in encoding `enc` as a string.
303
+ """
304
+ Base. readall (s:: IO , enc:: ASCIIString ) = readall (StringDecoder (s, enc))
305
+ Base. readall (filename:: AbstractString , enc:: ASCIIString ) = open (io-> readall (io, enc), filename)
290
306
end
291
307
292
308
@@ -330,6 +346,7 @@ function encode(s::AbstractString, enc::ASCIIString)
330
346
takebuf_array (b)
331
347
end
332
348
349
+
333
350
# # Function to list supported encodings
334
351
include (" encodings.jl" )
335
352
0 commit comments