Skip to content

Commit

Permalink
Fix breakage due to JuliaLang/julia#51319
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
yuyichao committed Oct 30, 2023
1 parent 2a9f077 commit aa232cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions deps/depsutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ function _preserveas!(dest::Vector{UInt8}, ::Type{Cstring}, x::AbstractString)
end

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

Expand Down

0 comments on commit aa232cc

Please sign in to comment.