Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions lib/unicode_guards.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ defmodule Unicode.Guards do

@doc false
# Replaced by `is_graph/1`.
defguard is_visible(codepoint)
when is_integer(codepoint) and match?(codepoint, "[[:visible:]]")
defmacro is_visible(codepoint) do
quote generated: true, location: :keep do
is_integer(unquote(codepoint)) and match?(unquote(codepoint), "[[:visible:]]")
end
end

@doc """
Guards whether a UTF8 codepoint is a graphic character.
Expand All @@ -166,8 +169,11 @@ defmodule Unicode.Guards do
non-space, non-control and non-surrogate.

"""
defguard is_graph(codepoint)
when is_integer(codepoint) and match?(codepoint, "[[:graph:]]")
defmacro is_graph(codepoint) do
quote generated: true, location: :keep do
is_integer(unquote(codepoint)) and match?(unquote(codepoint), "[[:graph:]]")
end
end

@doc """
Guards whether a UTF8 codepoint is a space character.
Expand All @@ -187,6 +193,9 @@ defmodule Unicode.Guards do
`[:graph:]` set and the `[:blank:]` set.

"""
defguard is_print(codepoint)
when is_integer(codepoint) and match?(codepoint, "[[:print:]]")
defmacro is_print(codepoint) do
quote generated: true, location: :keep do
is_integer(unquote(codepoint)) and match?(unquote(codepoint), "[[:print:]]")
end
end
end