Skip to content

Commit 0aa5cd3

Browse files
committedMay 7, 2015
Merge pull request #11175 from ScottPJones/spj/validchar
Fix #11171 is_valid_char
2 parents cd2c363 + 5b00772 commit 0aa5cd3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎base/utf8proc.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ export normalize_string, graphemes, is_valid_char, is_assigned_char, charwidth,
1212
islower, isupper, isalpha, isdigit, isnumber, isalnum,
1313
iscntrl, ispunct, isspace, isprint, isgraph, isblank
1414

15-
# whether codepoints are valid Unicode
16-
is_valid_char(c::Union(UInt8,UInt16,UInt32,Char)) = ccall(:utf8proc_codepoint_valid, Cuchar, (UInt32,), c)!=0
17-
is_valid_char(c::Integer) = (0x0 <= c <= 0x110000) && is_valid_char(UInt32(c))
15+
# whether codepoints are valid Unicode scalar values, i.e. 0-0xd7ff, 0xe000-0x10ffff
16+
is_valid_char(ch::Unsigned) = !Bool((ch-0xd800<0x800)|(ch>0x10ffff))
17+
is_valid_char(ch::Integer) = is_valid_char(Unsigned(ch))
18+
is_valid_char(ch::Char) = is_valid_char(UInt32(ch))
1819

1920
# utf8 category constants
2021
const UTF8PROC_CATEGORY_CN = 0

0 commit comments

Comments
 (0)
Please sign in to comment.