File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,15 @@ defmodule String.Unicode do
14
14
15
15
# WhiteSpace.txt is extracted from Unicode's PropList.txt (just the White_Space property)
16
16
prop_path = Path . join ( __DIR__ , "WhiteSpace.txt" )
17
- prop_range_line_regex = ~r / \A ([0-9A-F]{4})(?: \. \. ([0-9A-F]{4}))? /
17
+
18
18
whitespace = Enum . reduce File . stream! ( prop_path ) , [ ] , fn ( line , acc ) ->
19
- case Regex . run ( prop_range_line_regex , line , capture: :all_but_first ) do
20
- [ single ] ->
19
+ case line |> :binary . split ( ";" ) |> hd do
20
+ << first :: 4 - bytes , ".." , last :: 4 - bytes , _ :: binary >> ->
21
+ first = String . to_integer ( first , 16 )
22
+ last = String . to_integer ( last , 16 )
23
+ Enum . map ( first .. last , & to_binary . ( Integer . to_string ( & 1 , 16 ) ) ) ++ acc
24
+ << single :: 4 - bytes , _ :: binary >> ->
21
25
[ to_binary . ( single ) | acc ]
22
- [ first , last ] ->
23
- range = String . to_integer ( first , 16 ) .. String . to_integer ( last , 16 )
24
- acc ++ Enum . map ( range , & to_binary . ( Integer . to_string ( & 1 , 16 ) ) )
25
- _ ->
26
- acc
27
26
end
28
27
end
29
28
You can’t perform that action at this time.
0 commit comments