@@ -285,8 +285,24 @@ function read(s::StringDecoder, ::Type{UInt8})
285285 eof(s) ? throw(EOFError()) : s. outbuf[s. skip+= 1 ]
286286end
287287
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)
290306end
291307
292308
@@ -330,6 +346,7 @@ function encode(s::AbstractString, enc::ASCIIString)
330346 takebuf_array(b)
331347end
332348
349+
333350# # Function to list supported encodings
334351include(" encodings.jl" )
335352
0 commit comments