Skip to content

Commit aa232cc

Browse files
committed
Fix breakage due to JuliaLang/julia#51319
`cconvert` does not return an array anymore and cannot be used with `reinterpret`. Fix to use the underlying `transcode` function directly, which is also consistent with the `Cstring` version.
1 parent 2a9f077 commit aa232cc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

deps/depsutils.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ function _preserveas!(dest::Vector{UInt8}, ::Type{Cstring}, x::AbstractString)
6464
end
6565

6666
function _preserveas!(dest::Vector{UInt8}, ::Type{Cwstring}, x::AbstractString)
67-
s = reinterpret(UInt8, Base.cconvert(Cwstring, x))
68-
copyto!(resize!(dest, length(s)), s)
67+
s = reinterpret(UInt8, transcode(Cwchar_t, String(x)))
68+
len = length(s)
69+
copyto!(resize!(dest, len + sizeof(Cwchar_t)), s)
70+
dest[len + 1:len + sizeof(Cwchar_t)] .= 0
6971
return pointer(dest)
7072
end
7173

0 commit comments

Comments
 (0)