Revision 9b8e5755d39111293d8613be5355668efe19dfe7 authored by Simon Byrne on 02 December 2023, 20:33:33 UTC, committed by Simon Byrne on 02 December 2023, 20:33:33 UTC
1 parent f2df9d3
withlocales.jl
# This file is a part of Julia. License is MIT: https://julialang.org/license
function withlocales(f, newlocales)
# save current locales
locales = Dict{Int,String}()
for cat in 0:9999
cstr = ccall(:setlocale, Cstring, (Cint, Cstring), cat, C_NULL)
if cstr != C_NULL
locales[cat] = unsafe_string(cstr)
end
end
try
# change to each of given locales
for lc in newlocales
set = true
for (cat, _) in locales
set &= ccall(:setlocale, Cstring, (Cint, Cstring), cat, lc) != C_NULL
end
set && f(lc)
end
finally
# recover locales
for (cat, lc) in locales
cstr = ccall(:setlocale, Cstring, (Cint, Cstring), cat, lc)
end
end
end
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...