title: How to compare Chinese characters in Java using 'equals()'
body: <p>I want to compare a string portion (i.e. character) against a Chinese character. I assume due to the Unicode encoding it counts as two characters, so I'm looping through the string with increments of two. Now I ran into a roadblock where I'm trying to detect the '兒' character, but <code>equals()</code> doesn't match it, so what am I missing ? This is the code snippet:</p>
  
  <pre class="lang-html prettyprint-override"><code>for (int CharIndex = 0; CharIndex &lt; tmpChar.length(); CharIndex=CharIndex+2) {
  
     // Account for 'r' like in dianr/huir
     if (tmpChar.substring(CharIndex,CharIndex+2).equals("兒")) {
  </code></pre>
  
  
  
  <p>Also, feel free to suggest a more elegant way to parse this ...</p>
  
  <p><strong>[UPDATE]</strong> Some pics from the debugger, showing that it doesn't match, even though it should. I pasted the Chinese character from the spreadsheet I use as input, so I don't think it's a copy and paste issue (unless the unicode gets lost along the way)  </p>
  
  <p><a href="https://i.stack.imgur.com/sFdrT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sFdrT.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/RGHq3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RGHq3.png" alt="enter image description here"></a></p>
  
  <p>oh, dang, apparently it does not work simply copy and pasting:  </p>
  
  <p><a href="https://i.stack.imgur.com/xw3Rs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xw3Rs.png" alt="enter image description here"></a></p>