Skip to content

Instantly share code, notes, and snippets.

@graingert
Forked from anonymous/1a.java
Created Feb 10, 2012
Embed
What would you like to do?
/**
* @param word String to be turned into T9 code
* @return the T9 code of the input string
*
* Method returns the order of buttons of digipad buttons to be pressed to
* get the input String from a T9 predictive text dictionary.
*
* This method assumes the order of the buttons is as follows and ignores case:
*
* 2= a,b,c
* 3= d,e,f
* 4= g,h,i
* 5= j,k,l
* 6= m,n,o
* 7= p,q,r,s
* 8= t,u,v
* 9= w,x,y,z
*
* punctuation of any kind is replaced with a " ".
*
*/
public static String wordToSignature(String word){
char[] code = word.toLowercase().toCharArray();
for (int i=1; i<code.length; i++){
switch(code[i]){
case 'a':
case 'b':
case 'c':
code[i] = '1';
break;
...
default:
code[i] = ' ';
break;
}
return new String(code);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment