View Source Unicode.Unihan.Radical (Unicode v0.3.0)
Unicode.Unihan.Radical
encapsulates the mapping from CJK radical numbers
to characters.
Link to this section Summary
Functions
Filter the Unicode CJK radical database returning selected codepoints.
Returns grapheme associated with the radical, as specified in the CJK Radicals file.
Filter the Unicode CJK radical database returning selected codepoints that are not rejected by the provided function.
Link to this section Functions
Filter the Unicode CJK radical database returning selected codepoints.
arguments
Arguments
fun
is a1-arity
function that is passed the attribute map for a given codepoint. if the function returns atruthy
value then the codepoint is included in the returned data. If the return value isfalsy
then the codepoint is omitted from the returned list.
returns
Returns
- a map of the filtered codepoints mapped to their attributes.
example
Example
iex> Unicode.Unihan.Radical.filter(&(&1[:Hant][:radical_number] < 5))
...> |> Enum.count()
4
Returns grapheme associated with the radical, as specified in the CJK Radicals file.
arguments
Arguments
index
is the Unicode radical number (1..214), reported from various radical stroke properties such askRSUnicode
.an optional argument, which can be one of:
:unified_ideograph
(default) shows the grapheme in the (normal) CJK unified ideograph Unicode block (hexadecimal 4000--6000):radical_character
shows the grapheme in the special, contiguous KangXi Radical block (2F00--2FD5):all
returns the full map for the radical
examples
Examples
iex> Unicode.Unihan.Radical.radical(187)
"馬"
iex> Unicode.Unihan.Radical.radical(187, script: :Hans)
"马"
iex> Unicode.Unihan.Radical.radical(187, script: :Hant, glyph: :radical_character)
"⾺"
iex> Unicode.Unihan.Radical.radical(187) == Unicode.Unihan.Radical.radical(187, script: :Hant, glyph: :radical_character)
false
iex> Unicode.Unihan.Radical.radical(187, :all)
%{
Hans: %{
radical_character: 12002,
radical_number: 187,
unified_ideograph: 39532
},
Hant: %{
radical_character: 12218,
radical_number: 187,
unified_ideograph: 39340
}
}
iex> Unicode.Unihan.Radical.radical(999)
{:error, "Invalid radical number. Valid numbers are an integer in the range 1..214"}
Filter the Unicode CJK radical database returning selected codepoints that are not rejected by the provided function.
arguments
Arguments
fun
is a1-arity
function that is passed the attribute map for a given codepoint. if the function returns afalsy
value then the codepoint is included in the returned data. If the return value istruthy
then the codepoint is omitted from the returned list.
returns
Returns
- a map of the codepoints that are not rejected mapped to their attributes.
example
Example
iex> Unicode.Unihan.Radical.reject(&(&1[:Hant][:radical_number] < 5))
...> |> Enum.count()
210