为汉语名字生成首字母助记码
2013-08-07 13:25
148 查看
{生成字符串的助记码 }
Function GetZJM(Value: String):String;
var
I, L: Integer;
C: array[0..1] of Char;
R: Char;
begin
Result := '';
L := Length(Value);
I := 1;
while I <= (L - 1) do
begin
if Value[I] <= #128 then
begin
Result := Result + Value[I];
Inc(I);
end
else if Value[I] < #160 then
begin
Result := Result + Value[I];
Inc(I,2);
end
else
begin
C[0] := Value[I];
C[1] := Value[I + 1];
R := GetHZM(C);
if R <> #0 then
Result := Result + R;
Inc(I, 2);
end;
end;
if I = L then
Result := Result + Value[L];
end;
{获取汉字字符串的拼音码}
Function GetHZM(Value: array of char): Char;
begin
Result := #0;
case Byte(Value[0]) of
176:
case Byte(Value[1]) of
161..196: Result := 'A';
197..254: Result := 'B';
end;
177: Result := 'B';
178:
case Byte(Value[1]) of
161..192: Result := 'B';
193..205: Result := 'C';
206: Result := 'S';
207..254: Result := 'C';
end;
179: Result := 'C';
180:
case Byte(Value[1]) of
161..237: Result := 'C';
238..254: Result := 'D';
end;
181: Result := 'D';
182:
case Byte(Value[1]) of
161..233: Result := 'D';
234..254: Result := 'E';
end;
183:
case Byte(Value[1]) of
161: Result := 'E';
162..254: Result := 'F';
end;
184:
case Byte(Value[1]) of
161..192: Result := 'F';
193..254: Result := 'G';
end;
185:
case Byte(Value[1]) of
161..253: Result := 'G';
254: Result := 'H';
end;
186: Result := 'H';
187:
case Byte(Value[1]) of
161..246: Result := 'H';
247..254: Result := 'J';
end;
188..190: Result := 'J';
191:
case Byte(Value[1]) of
161..165: Result := 'J';
166..254: Result := 'K';
end;
192:
case Byte(Value[1]) of
161..171: Result := 'K';
172..254: Result := 'L';
end;
193: Result := 'L';
194:
case Byte(Value[1]) of
161..231: Result := 'L';
232..254: Result := 'M';
end;
195: Result := 'M';
196:
case Byte(Value[1]) of
161..194: Result := 'M';
195..254: Result := 'N';
end;
197:
case Byte(Value[1]) of
161..181: Result := 'N';
182..189: Result := 'O';
190..254: Result := 'P';
end;
198:
case Byte(Value[1]) of
161..217: Result := 'P';
218..254: Result := 'Q';
end;
199: Result := 'Q';
200:
case Byte(Value[1]) of
161..186: Result := 'Q';
187..245: Result := 'R';
246..254: Result := 'S';
end;
201..202: Result := 'S';
203:
case Byte(Value[1]) of
161..249: Result := 'S';
250..254: Result := 'T';
end;
204: Result := 'T';
205:
case Byte(Value[1]) of
161..217: Result := 'T';
218..254: Result := 'W';
end;
206:
case Byte(Value[1]) of
161..243: Result := 'W';
244..254: Result := 'X';
end;
207..208: Result := 'X';
209:
case Byte(Value[1]) of
161..184: Result := 'X';
185..254: Result := 'Y';
end;
210..211: Result := 'Y';
212:
case Byte(Value[1]) of
161..208: Result := 'Y';
209..254: Result := 'Z';
end;
213..215: Result := 'Z';
216..247:
Result := ChnPy[Byte(Value[0])][Byte(Value[1]) - 160];
end;
end;
Function GetZJM(Value: String):String;
var
I, L: Integer;
C: array[0..1] of Char;
R: Char;
begin
Result := '';
L := Length(Value);
I := 1;
while I <= (L - 1) do
begin
if Value[I] <= #128 then
begin
Result := Result + Value[I];
Inc(I);
end
else if Value[I] < #160 then
begin
Result := Result + Value[I];
Inc(I,2);
end
else
begin
C[0] := Value[I];
C[1] := Value[I + 1];
R := GetHZM(C);
if R <> #0 then
Result := Result + R;
Inc(I, 2);
end;
end;
if I = L then
Result := Result + Value[L];
end;
{获取汉字字符串的拼音码}
Function GetHZM(Value: array of char): Char;
begin
Result := #0;
case Byte(Value[0]) of
176:
case Byte(Value[1]) of
161..196: Result := 'A';
197..254: Result := 'B';
end;
177: Result := 'B';
178:
case Byte(Value[1]) of
161..192: Result := 'B';
193..205: Result := 'C';
206: Result := 'S';
207..254: Result := 'C';
end;
179: Result := 'C';
180:
case Byte(Value[1]) of
161..237: Result := 'C';
238..254: Result := 'D';
end;
181: Result := 'D';
182:
case Byte(Value[1]) of
161..233: Result := 'D';
234..254: Result := 'E';
end;
183:
case Byte(Value[1]) of
161: Result := 'E';
162..254: Result := 'F';
end;
184:
case Byte(Value[1]) of
161..192: Result := 'F';
193..254: Result := 'G';
end;
185:
case Byte(Value[1]) of
161..253: Result := 'G';
254: Result := 'H';
end;
186: Result := 'H';
187:
case Byte(Value[1]) of
161..246: Result := 'H';
247..254: Result := 'J';
end;
188..190: Result := 'J';
191:
case Byte(Value[1]) of
161..165: Result := 'J';
166..254: Result := 'K';
end;
192:
case Byte(Value[1]) of
161..171: Result := 'K';
172..254: Result := 'L';
end;
193: Result := 'L';
194:
case Byte(Value[1]) of
161..231: Result := 'L';
232..254: Result := 'M';
end;
195: Result := 'M';
196:
case Byte(Value[1]) of
161..194: Result := 'M';
195..254: Result := 'N';
end;
197:
case Byte(Value[1]) of
161..181: Result := 'N';
182..189: Result := 'O';
190..254: Result := 'P';
end;
198:
case Byte(Value[1]) of
161..217: Result := 'P';
218..254: Result := 'Q';
end;
199: Result := 'Q';
200:
case Byte(Value[1]) of
161..186: Result := 'Q';
187..245: Result := 'R';
246..254: Result := 'S';
end;
201..202: Result := 'S';
203:
case Byte(Value[1]) of
161..249: Result := 'S';
250..254: Result := 'T';
end;
204: Result := 'T';
205:
case Byte(Value[1]) of
161..217: Result := 'T';
218..254: Result := 'W';
end;
206:
case Byte(Value[1]) of
161..243: Result := 'W';
244..254: Result := 'X';
end;
207..208: Result := 'X';
209:
case Byte(Value[1]) of
161..184: Result := 'X';
185..254: Result := 'Y';
end;
210..211: Result := 'Y';
212:
case Byte(Value[1]) of
161..208: Result := 'Y';
209..254: Result := 'Z';
end;
213..215: Result := 'Z';
216..247:
Result := ChnPy[Byte(Value[0])][Byte(Value[1]) - 160];
end;
end;
相关文章推荐
- Sql随机生成一个汉语名字
- 利用python操作android的xml资源文件,让其按照中文自动生成对应中文首字母加起来的名字,并且根据中文在java类里面替代对应的中文
- C# 写的一个生成随机汉语名字的小程序
- javascript 随机取任意四个字母和随机生成一个名字
- java生成四位随机数,包含数字和字母 区分大小写,特别适合做验证码,android开发
- 修改eclipse自动生成的comments中的author名字
- 取文件名的后缀 4位文件名(字母) 生成不重复文件名(小写字母与数字)
- 根据类的名字String生成相应的类
- 随机生成6位验证码或密码(字母和数字组合)
- Python实现将不规范的英文名字首字母大写
- C# 汉语生成拼音(微软官方方案)
- 随机生成几位数字字母组合
- java 生成随机数字或者字母
- Java生成随机字母和数字
- PowerDesigner之设置(3)——根据Name首字母生成Code
- Java版纯字母、纯数字、字母数字组合验证码的生成
- Java 随机数工具类(可指定字母或数字生成)
- python中把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字。
- JS基础篇--通过JS生成由字母与数字组合的随机字符串
- php随机生成指定长度的字符串 可以固定数字 字母 混合