Skip to content

Commit

Permalink
eliminate copy for Unicode.normalize of substring (JuliaLang#38381)
Browse files Browse the repository at this point in the history
eliminate copy for Unicode.normalize of substring
  • Loading branch information
stevengj committed Nov 11, 2020
1 parent 9c498bf commit af3cd59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/strings/unicode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const UTF8PROC_STRIPMARK = (1<<13)

utf8proc_error(result) = error(unsafe_string(ccall(:utf8proc_errmsg, Cstring, (Cssize_t,), result)))

function utf8proc_map(str::String, options::Integer)
function utf8proc_map(str::Union{String,SubString{String}}, options::Integer)
nwords = ccall(:utf8proc_decompose, Int, (Ptr{UInt8}, Int, Ptr{UInt8}, Int, Cint),
str, sizeof(str), C_NULL, 0, options)
nwords < 0 && utf8proc_error(nwords)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Unicode/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Unicode: normalize, isassigned

@testset "string normalization" begin
# normalize (Unicode normalization etc.):
@test normalize("\u006e\u0303", :NFC) == "\u00f1"
@test normalize("\u006e\u0303", :NFC) == "\u00f1" == normalize(SubString("ab\u006e\u0303cd",3,4), :NFC)
@test "\u006e\u0303" == normalize("\u00f1", :NFD)
@test normalize("\ufb00", :NFC) != "ff"
@test normalize("\ufb00", :NFKC) == "ff"
Expand Down

0 comments on commit af3cd59

Please sign in to comment.