txt: ## chars.md
  chars
  
  Combined from primary sources listed below.
  
  # [In Match](#___top "go to top of document")[§](#(Match)_method_chars "direct link")
  
  See primary documentation
  [in context](/type/Match#method_chars)
  for **method chars**.
  
  ```raku
  method chars()
  ```
  
  Returns the numbers of characters in the matched string or 0 if there's been no match.
  
  Returns the same as `.Str.chars`.
  
  # [In role Blob](#___top "go to top of document")[§](#(role_Blob)_method_chars "direct link")
  
  See primary documentation
  [in context](/type/Blob#method_chars)
  for **method chars**.
  
  ```raku
  method chars(Blob:D:)
  ```
  
  Throws [`X::Buf::AsStr`](/type/X/Buf/AsStr) with `chars` as payload.
  
  # [In Str](#___top "go to top of document")[§](#(Str)_routine_chars "direct link")
  
  See primary documentation
  [in context](/type/Str#routine_chars)
  for **routine chars**.
  
  ```raku
  multi        chars(Cool  $x --> Int:D)
  multi        chars(Str:D $x --> Int:D)
  multi        chars(str   $x --> int)
  multi method chars(Str:D:   --> Int:D)
  ```
  
  Returns the number of characters in the string in graphemes. On the JVM, this currently erroneously returns the number of codepoints instead.
  
  # [In Cool](#___top "go to top of document")[§](#(Cool)_routine_chars "direct link")
  
  See primary documentation
  [in context](/type/Cool#routine_chars)
  for **routine chars**.
  
  ```raku
  multi  chars(Cool $x)
  multi  chars(Str:D $x)
  multi  chars(str $x --> int)
  method chars(--> Int:D)
  ```
  
  Coerces the invocant (or in sub form, its argument) to [`Str`](/type/Str), and returns the number of characters in the string. Please note that on the JVM, you currently get codepoints instead of graphemes.
  
  ```raku
  say 'møp'.chars;    # OUTPUT: «3␤»
  say 'ã̷̠̬̊'.chars;     # OUTPUT: «1␤»
  say '👨‍👩‍👧‍👦🏿'.chars;    # OUTPUT: «1␤»
  ```
  
  If the string is native, the number of chars will be also returned as a native `int`.
  
  Graphemes are user visible characters. That is, this is what the user thinks of as a “character”.
  
  Graphemes can contain more than one codepoint. Typically the number of graphemes and codepoints differs when `Prepend` or `Extend` characters are involved (also known as [Combining characters](https://en.wikipedia.org/wiki/Combining_character)), but there are many other cases when this may happen. Another example is `\c[ZWJ]` ([Zero-width joiner](https://en.wikipedia.org/wiki/Zero-width_joiner)).
  
  You can check `Grapheme_Cluster_Break` property of a character in order to see how it is going to behave:
  
  ```raku
  say ‘ã̷̠̬̊’.uniprops(‘Grapheme_Cluster_Break’); # OUTPUT: «(Other Extend Extend Extend Extend)␤»
  say ‘👨‍👩‍👧‍👦🏿’.uniprops(‘Grapheme_Cluster_Break’); # OUTPUT: «(E_Base_GAZ ZWJ E_Base_GAZ ZWJ E_Base_GAZ ZWJ E_Base_GAZ E_Modifier)␤»
  ```
  
  You can read more about graphemes in the [Unicode Standard](https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries), which Raku tightly follows, using a method called [NFG, normal form graphemes](/language/glossary#NFG) for efficiently representing them.
  