diff --git a/base/stream.jl b/base/stream.jl index 5799fe4458537..f58ab568437af 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -771,12 +771,13 @@ function write(s::AsyncStream, b::UInt8) return 1 end function write(s::AsyncStream, c::Char) - @uv_write utf8sizeof(c) ccall(:jl_pututf8_copy, Int32, (Ptr{Void},UInt32, Ptr{Void}, Ptr{Void}), handle(s), c, uvw, uv_jl_writecb_task::Ptr{Void}) + nb = utf8sizeof(c) + @uv_write nb ccall(:jl_pututf8_copy, Int32, (Ptr{Void}, UInt32, Ptr{Void}, Ptr{Void}), handle(s), c, uvw, uv_jl_writecb_task::Ptr{Void}) ct = current_task() uv_req_set_data(uvw,ct) ct.state = :waiting stream_wait(ct) - return utf8sizeof(c) + return nb end function write{T}(s::AsyncStream, a::Array{T}) if isbits(T) diff --git a/base/string.jl b/base/string.jl index 86c9e3fd0f6f2..71231e0951c7e 100644 --- a/base/string.jl +++ b/base/string.jl @@ -587,7 +587,8 @@ write{T<:ByteString}(to::IOBuffer, s::SubString{T}) = s.endof==0 ? 0 : write_sub(to, s.string.data, s.offset+1, next(s,s.endof)[2]-1) print(io::IOBuffer, s::SubString) = write(io, s) -sizeof{T<:ByteString}(s::SubString{T}) = s.endof==0 ? 0 : next(s,s.endof)[2]-1 +sizeof(s::SubString{ASCIIString}) = s.endof +sizeof(s::SubString{UTF8String}) = s.endof == 0 ? 0 : next(s,s.endof)[2]-1 # TODO: length(s::SubString) = ?? # default implementation will work but it's slow