@@ -46,7 +46,6 @@ const UTF8PROC_CATEGORY_CF = 27
46
46
const UTF8PROC_CATEGORY_CS = 28
47
47
const UTF8PROC_CATEGORY_CO = 29
48
48
49
- const UTF8PROC_NULLTERM = (1 << 0 )
50
49
const UTF8PROC_STABLE = (1 << 1 )
51
50
const UTF8PROC_COMPAT = (1 << 2 )
52
51
const UTF8PROC_COMPOSE = (1 << 3 )
@@ -64,22 +63,21 @@ const UTF8PROC_STRIPMARK = (1<<13)
64
63
65
64
# ###########################################################################
66
65
67
- let
68
- const p = Array (Ptr{UInt8}, 1 )
69
- global utf8proc_map
70
- function utf8proc_map (s:: AbstractString , flags:: Integer )
71
- result = ccall (:utf8proc_map , Cssize_t,
72
- (Ptr{UInt8}, Cssize_t, Ptr{Ptr{UInt8}}, Cint),
73
- s, 0 , p, flags | UTF8PROC_NULLTERM)
74
- result < 0 && error (bytestring (ccall (:utf8proc_errmsg , Ptr{UInt8},
75
- (Cssize_t,), result)))
76
- a = ccall (:jl_ptr_to_array_1d , Vector{UInt8},
77
- (Any, Ptr{UInt8}, Csize_t, Cint),
78
- Vector{UInt8}, p[1 ], result, true )
79
- ccall (:jl_array_to_string , Any, (Any,), a):: ByteString
80
- end
66
+ function utf8proc_map (s:: ByteString , flags:: Integer )
67
+ p = Ref {Ptr{UInt8}} ()
68
+ result = ccall (:utf8proc_map , Cssize_t,
69
+ (Ptr{UInt8}, Cssize_t, Ref{Ptr{UInt8}}, Cint),
70
+ s, sizeof (s), p, flags)
71
+ result < 0 && error (bytestring (ccall (:utf8proc_errmsg , Ptr{UInt8},
72
+ (Cssize_t,), result)))
73
+ a = ccall (:jl_ptr_to_array_1d , Vector{UInt8},
74
+ (Any, Ptr{UInt8}, Csize_t, Cint),
75
+ Vector{UInt8}, p[], result, true )
76
+ ccall (:jl_array_to_string , Any, (Any,), a):: ByteString
81
77
end
82
78
79
+ utf8proc_map (s:: AbstractString , flags:: Integer ) = utf8proc_map (bytestring (s), flags)
80
+
83
81
function normalize_string (s:: AbstractString ; stable:: Bool = false , compat:: Bool = false , compose:: Bool = true , decompose:: Bool = false , stripignore:: Bool = false , rejectna:: Bool = false , newline2ls:: Bool = false , newline2ps:: Bool = false , newline2lf:: Bool = false , stripcc:: Bool = false , casefold:: Bool = false , lump:: Bool = false , stripmark:: Bool = false )
84
82
flags = 0
85
83
stable && (flags = flags | UTF8PROC_STABLE)
0 commit comments