Skip to content

Commit f33e029

Browse files
committed
Fix due to reinterpret behavior change in 0.7
JuliaLang/julia#21831
1 parent 82f4e00 commit f33e029

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/CosObjectHelpers.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ function convert(::Type{CDTextString}, xstr::CosXString)
1111
data = xstr.val
1212
buffer = data |> String |> hex2bytes
1313
if prefix == feff || prefix == FEFF
14+
len2 = div(length(buffer),2)
15+
utf_16_arr = Vector{UInt16}(len2-1)
16+
utf_16_data = reinterpret(UInt8, utf_16_arr)
1417
if (0x04030201 == ENDIAN_BOM)
15-
len2 = div(length(buffer),2)
1618
for i=1:len2
1719
(buffer[2i-1], buffer[2i]) = (buffer[2i], buffer[2i-1])
1820
end
1921
end
20-
utf_16_data = reinterpret(UInt16, buffer[3:end])
21-
str = transcode(String, utf_16_data)
22+
copy!(utf_16_data, 1, buffer, 3, 2len2-2)
23+
str = transcode(String, utf_16_arr)
2224
else
2325
# Assume PDFDocEncoding (ISO-8859-1)
2426
str = StringEncodings.decode(buffer, "ISO_8859-1")

0 commit comments

Comments
 (0)