1、Java代码public class FirstLetter /字母Z使用了两个 标签,这里有个值/i, u, v都不做声母, 跟随前面的字母private char chartable =啊 , 芭 , 擦 , 搭, 蛾, 发, 噶, 哈, 哈,击 , 喀 , 垃 , 妈, 拿, 哦, 啪, 期, 然,撒 , 塌 , 塌 , 塌, 挖, 昔, 压, 匝, 座;private char alphatable =A, B, C, D, E, F, G, H, I,J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;private int table
2、 = new int27;/初始化for (int i = 0; i = a elsereturn alphatablei;/根据一个包含汉字的字符串返回一个汉字拼音首字母的字符串public String String2Alpha(String SourceStr) String Result = “;int StrLength = SourceStr.length();int i;try for (i = 0; i StrLength; i+) Result += Char2Alpha(SourceStr.charAt(i); catch (Exception e) Result = “;
3、return Result;private boolean match(int i, int gb) if (gb tablei)return false;int j = i + 1;/字母Z使用了两个 标签while (j 26 if (j = 26)return gb = tablej;elsereturn gb tablej;/取出汉字的编码private int gbValue(char ch) String str = new String();str += ch;try byte bytes = str.getBytes(“GB2312“);if (bytes.length 2)return 0;return (bytes0 8 catch (Exception e) return 0;获取方法(new FirstLetter().String2Alpha(“中国”).substring(0, 1);/获得首字母字母new FirstLetter().String2Alpha(“中国”);获取全部