public static String sanitizeIdentifierName(String input){
  if (input == null || input.isEmpty()) {
    return input;
  }
  final StringBuilder result=new StringBuilder();
  char ch=input.charAt(0);
  if (Character.isJavaIdentifierStart(ch)) {
    result.append(ch);
  }
 else {
    result.append("_" + Character.codePointAt(input,0) + "$");
  }
  int i=1;
  while (i < input.length()) {
    ch=input.charAt(i);
    if (Character.isJavaIdentifierPart(ch)) {
      result.append(ch);
    }
 else {
      result.append("_" + Character.codePointAt(input,i) + "$");
    }
    i=i + 1;
  }
  return result.toString();
}

public static String sanitizeIdentifierName ( String input ) { if ( input == null || input . isEmpty ( ) ) { return input ; } final StringBuilder result = new StringBuilder ( ) ; char ch = input . charAt ( 0 ) ; if ( Character . isJavaIdentifierStart ( ch ) ) { result . append ( ch ) ; } else { result . append ( "_" + Character . codePointAt ( input , 0 ) + "$" ) ; } int i = 1 ; while ( i < input . length ( ) ) { ch = input . charAt ( i ) ; if ( Character . isJavaIdentifierPart ( ch ) ) { result . append ( ch ) ; } else { result . append ( "_" + Character . codePointAt ( input , i ) + "$" ) ; } i = i + 1 ; } return result . toString ( ) ; }
escapes illegal characters in given identifier . used for function names , etc .
