Skip to content

Commit

Permalink
Fix due to reinterpret behavior change in 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sambitdash committed Aug 24, 2017
1 parent 82f4e00 commit f33e029
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/CosObjectHelpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ function convert(::Type{CDTextString}, xstr::CosXString)
data = xstr.val
buffer = data |> String |> hex2bytes
if prefix == feff || prefix == FEFF
len2 = div(length(buffer),2)
utf_16_arr = Vector{UInt16}(len2-1)
utf_16_data = reinterpret(UInt8, utf_16_arr)
if (0x04030201 == ENDIAN_BOM)
len2 = div(length(buffer),2)
for i=1:len2
(buffer[2i-1], buffer[2i]) = (buffer[2i], buffer[2i-1])
end
end
utf_16_data = reinterpret(UInt16, buffer[3:end])
str = transcode(String, utf_16_data)
copy!(utf_16_data, 1, buffer, 3, 2len2-2)
str = transcode(String, utf_16_arr)
else
# Assume PDFDocEncoding (ISO-8859-1)
str = StringEncodings.decode(buffer, "ISO_8859-1")
Expand Down

0 comments on commit f33e029

Please sign in to comment.