takebuf_string
takebuf_string(b::IOBuffer)
Obtain the contents of an IOBuffer
as a string, without copying. Afterwards, the IOBuffer is reset to its initial state.
Examples
julia> buffer = IOBuffer("Hello, world!")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=13, maxsize=Inf, ptr=1, mark=-1)
julia> takebuf_string(buffer)
"Hello, world!"
julia> takebuf_string(buffer)
""
In the above examples, we create an IOBuffer
with the initial content "Hello, world!". The takebuf_string
function is then used to obtain the contents of the buffer as a string. After calling takebuf_string
, the buffer is reset to its initial state, so subsequent calls to takebuf_string
will return an empty string.
See Also
ascii, base64decode, Base64DecodePipe, base64encode, Base64EncodePipe, bin, bits, bytestring, charwidth, chomp, chop, chr2ind, contains, endswith, escape_string, graphemes, ind2chr, iscntrl, istext, isupper, isvalid, join, lcfirst, lowercase, lpad, lstrip, normalize_string, num2hex, parseip, randstring, readuntil, replace, repr, rpad, rsplit, rstrip, search, searchindex, split, startswith, string, stringmime, strip, strwidth, summary, takebuf_string, ucfirst, unescape_string, uppercase, utf16, utf32, utf8, wstring,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.