title: Rust - How to parse UTF-8 alphabetical characters in nom?
body: <p>I am trying to parse character sequences of alphabetical characters, including german umlauts (ä ö ü) and other alphabetical characters from the UTF-8 charset.
  This is the parser I tried first:</p>
  
  <pre class="lang-rust prettyprint-override"><code>named!(
      parse(&amp;'a str) -&gt; Self,
      map!(
          alpha1,
          |s| Self { chars: s.into() }
      )
  );
  </code></pre>
  
  <p>But it only works for ASCII alphabetical characters (a-zA-Z).
  I tried to perform the parsing <code>char</code> by <code>char</code>:</p>
  
  <pre class="lang-rust prettyprint-override"><code>named!(
      parse(&amp;str) -&gt; Self,
      map!(
          take_while1!(nom::AsChar::is_alpha),
          |s| Self { chars: s.into() }
      )
  );
  </code></pre>
  
  <p>But this won't even parse "hello", but result in an <code>Incomplete(Size(1))</code> error:</p>
  
  <p>How do you parse UTF-8 alphabetical characters in <a href="https://github.com/Geal/nom" rel="nofollow noreferrer">nom</a>?
  A snippet from my code:</p>
  
  <pre class="lang-rust prettyprint-override"><code>extern crate nom;
  
  #[derive(PartialEq, Debug, Eq, Clone, Hash, Ord, PartialOrd)]
  pub struct Word {
      chars: String,
  }
  
  impl From&lt;&amp;str&gt; for Word {
      fn from(s: &amp;str) -&gt; Self {
          Self {
              chars: s.into(),
          }
      }
  }
  
  use nom::*;
  impl Word {
      named!(
          parse(&amp;str) -&gt; Self,
          map!(
              take_while1!(nom::AsChar::is_alpha),
              |s| Self { chars: s.into() }
          )
      );
  }
  
  
  #[test]
  fn parse_word() {
      let words = vec![
          "hello",
          "Hi",
          "aha",
          "Mathematik",
          "mathematical",
          "erfüllen"
      ];
      for word in words {
          assert_eq!(Word::parse(word).unwrap().1, Word::from(word));
      }
  }
  </code></pre>
  
  <p>When I run this test,</p>
  
  <pre><code>cargo test parse_word
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>thread panicked at 'called `Result::unwrap()` on an `Err` value: Incomplete(Size(1))', ...
  </code></pre>
  
  <p>I know that <code>char</code>s are already UTF-8 encoded in Rust (thank heavens, almighty), but it seems that the nom library is not behaving as I would expect. I am using <a href="https://docs.rs/nom/5.1.0/nom/" rel="nofollow noreferrer">nom 5.1.0</a></p>