implements InputFilter : UTF « Development « Android






implements InputFilter

 
//package divestoclimb.util;

import android.text.InputFilter;
import android.text.Spanned;

class ValidFilenameFilter implements InputFilter {

  public CharSequence filter(CharSequence source, int start, int end,
      Spanned dest, int dstart, int dend) {
    String valid = "";
    for(int i = start; i < end; i++) {
      char c = source.charAt(i);
      // These characters are the ones Windows doesn't
      // like, which appears to be the most restrictive
      // set. http://support.microsoft.com/kb/177506
      switch(c) {
      case '/':
      case '\\':
      case ':':
        c = '-';
        break;
      case '"':
        c = '\'';
        break;
      case '*':
      case '?':
      case '<':
      case '>':
      case '|':
        c = '_';
      }
      valid = valid.concat(String.valueOf(c));
    }
    return valid;
  }

}

   
  








Related examples in the same category

1.decode UTF8 to char
2.decode UTF8 to String
3.UTF 2 GBUtil
4.Load UTF8 encoded file to String
5.UTF8 to Byte Array