Skip to content

Commit

Permalink
iso8859_1_to_utf8 per #141
Browse files Browse the repository at this point in the history
  • Loading branch information
samoconnor committed Jan 14, 2018
1 parent be69847 commit 6d978be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export Message, Request, Response, HeaderSizeError,
header, hasheader, setheader, defaultheader, appendheader,
mkheaders, readheaders, headerscomplete, readtrailers, writeheaders,
readstartline!, writestartline,
bodylength, unknown_length
bodylength, unknown_length,
load

import ..HTTP

Expand Down Expand Up @@ -365,6 +366,16 @@ function Base.String(m::Message)
end


#Like https://github.com/JuliaIO/FileIO.jl/blob/v0.6.1/src/FileIO.jl#L19 ?
function load(m::Message)
if hasheader(m, "Content-Type", "ISO-8859-1")
return iso8859_1_to_utf8(m.body)
else
String(m.body)
end
end


"""
readstartline!(::Parsers.Message, ::Message)
Expand Down
1 change: 0 additions & 1 deletion src/Strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ end
Convert from ISO8859_1 to UTF8.
"""

iso8859_1_to_utf8(str::String) = iso8859_1_to_utf8(Vector{UInt8}(str))
function iso8859_1_to_utf8(bytes::Vector{UInt8})
io = IOBuffer()
for b in bytes
Expand Down

0 comments on commit 6d978be

Please sign in to comment.