title: Separating String on invisible character (tab, carriage return, group separator, etc)?
body: <p>I am trying to split a String in an Android app on certain characters. The characters are pound sign, comma, semicolon, tab, carriage return, group separator, unit separator, and record separator.</p>
  
  <p>Here's how I'm doing the splitting:</p>
  
  <pre><code>private ArrayList&lt;String&gt; splitdata(String data, String delimiter){
      ArrayList&lt;String&gt; fields = new ArrayList&lt;&gt;();
      int i = 0; int previous = 0; int index = 0;
      boolean first = true;
      while (i != -1) {
          i = data.indexOf(delimiter,i);
  
          if(i != -1){
              if (first) {
                  fields.add(data.substring(0, i));
                  first = false;
              } else {
                  fields.add(data.substring(previous + delimiter.length(), i));
              }
              Log.d(SCANNED_INTENT_TAG,"Newly found field: " + fields.get(index));
              index++;
              previous = i;
              i += delimiter.length();
          }
      }
      if (previous &lt; (data.length()-1) &amp;&amp; !first) {
          fields.add(data.substring(previous+1));
          Log.d(SCANNED_INTENT_TAG,"Newly found field: " + fields.get(index));
      }
      return fields;
  }
  </code></pre>
  
  <p>This works for visible characters that I can enter from the keyboard, such as the pound sign, comma, and semicolon. However, I cannot get it to detect the special characters tab, carriage return, group separator, unit separator, or record separator. I'm passing them in like this:</p>
  
  <pre><code>some_arraylist = splitdata(some_str,"\t");
  some_arraylist = splitdata(some_str,"\r");
  some_arraylist = splitdata(some_str,Character.toString((char) 31));
  some_arraylist = splitdata(some_str,Character.toString((char) 29));
  some_arraylist = splitdata(some_str,Character.toString((char) 28));
  </code></pre>
  
  <p>What should I be passing them in as?</p>