本人做了两个TEdit,要求在一个TEdit中输入一个汉字,另一个TEdit就显示此汉字的首字母,比如我输入一个‘我’字,,另一个TEdit显示w,我是初学者,不知道如何做,望哪个达人指点一下
解决方案 »
- 如何处理SQLSERVER中存储过程输出的IMAGE类型数据(不是返回字段,是输出值)
- [Error] Unit1.pas(114): Operator not applicable to this operand type问题
- 问一下,如何自动播放,请大家给个建议,谢谢
- 我想调用win32中的SetParent函数,但跟forms单元中的SetParent函数冲突,我怎么调用?
- Delphi应用打包的问题
- 请教: 在Excel中如何查找数据?
- 关于sql查询的问题!
- 请教Ado问题
- 立即给分.
- 关于xe, listview的问题。
- dbcombobox为什么不能为我列出所有的记录
- 【 求救!】有关Com实例化对象与数值型之间的转换问题???
Create function fun_getPY
(
@str nvarchar(4000)
)
returns nvarchar(4000)
as
begin declare @word nchar(1),@PY nvarchar(4000) set @PY='' while len(@str)>0
begin
set @word=left(@str,1) --如果非汉字字符,返回原字符
set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
then (
select top 1 PY
from
(
select 'A' as PY,N'驁' as word
union all select 'B',N'簿'
union all select 'C',N'錯'
union all select 'D',N'鵽'
union all select 'E',N'樲'
union all select 'F',N'鰒'
union all select 'G',N'腂'
union all select 'H',N'夻'
union all select 'J',N'攈'
union all select 'K',N'穒'
union all select 'L',N'鱳'
union all select 'M',N'旀'
union all select 'N',N'桛'
union all select 'O',N'漚'
union all select 'P',N'曝'
union all select 'Q',N'囕'
union all select 'R',N'鶸'
union all select 'S',N'蜶'
union all select 'T',N'籜'
union all select 'W',N'鶩'
union all select 'X',N'鑂'
union all select 'Y',N'韻'
union all select 'Z',N'咗'
) T
where word>=@word collate Chinese_PRC_CS_AS_KS_WS
order by PY ASC
)
else @word
end)
set @str=right(@str,len(@str)-1)
end return @PY end
B : (Key >= $B0C5) and (Key <= $B2C0)
C : (Key >= $B2C1) and (Key <= $B4ED)
D : (Key >= $B4EE) and (Key <= $B6E9)
E : (Key >= $B6EA) and (Key <= $B7A1)
F : (Key >= $B7A2) and (Key <= $B8C0)
G : (Key >= $B8C1) and (Key <= $B9FD)
H : (Key >= $B9FE) and (Key <= $BBF6)
J : (Key >= $BBF7) and (Key <= $BFA5)
K : (Key >= $BFA6) and (Key <= $C0AB)
L : (Key >= $C0AC) and (Key <= $C2E7)
M : (Key >= $C2E8) and (Key <= $C4C2)
N : (Key >= $C4C3) and (Key <= $C5B5)
O : (Key >= $C5B6) and (Key <= $C5BD)
P : (Key >= $C5BE) and (Key <= $C6D9)
Q : (Key >= $C6DA) and (Key <= $C8BA)
R : (Key >= $C8BB) and (Key <= $C8F5)
S : (Key >= $C8F6) and (Key <= $CBF9)
T : (Key >= $CBFA) and (Key <= $CDD9)
W : (Key >= $CDDA) and (Key <= $CEF3)
X : (Key >= $CEF4) and (Key <= $D188)
Y : (Key >= $D1B9) and (Key <= $D4D0)
Z : (Key >= $D4D1) and (Key <= $D7F9)
http://www.2ccc.com/article.asp?articleid=1314
将汉字反查为拼音的演示程序
http://www.2ccc.com/article.asp?articleid=12
function ChangeChineseToPY(aChinese:string):string;
function GetPYIndexChar(hzchar: string): Char;
begin
case Word(hzchar[1]) shl 8 + Word(hzchar[2]) of
$B0A1..$B0C4: Result := 'a';
$B0C5..$B2C0: Result := 'b';
$B2C1..$B4ED: Result := 'c';
$B4EE..$B6E9: Result := 'd';
$B6EA..$B7A1: Result := 'e';
$B7A2..$B8C0: Result := 'f';
$B8C1..$B9FD: Result := 'g';
$B9FE..$BBF6: Result := 'h';
$BBF7..$BFA5: Result := 'j';
$BFA6..$C0AB: Result := 'k';
$C0AC..$C2E7: Result := 'l';
$C2E8..$C4C2: Result := 'm';
$C4C3..$C5B5: Result := 'n';
$C5B6..$C5BD: Result := 'o';
$C5BE..$C6D9: Result := 'p';
$C6DA..$C8BA: Result := 'q';
$C8BB..$C8F5: Result := 'r';
$C8F6..$CBF9: Result := 's';
$CBFA..$CDD9: Result := 't';
$CDDA..$CEF3: Result := 'w';
$CEF4..$D188: Result := 'x';
$D1B9..$D4D0: Result := 'y';
$D4D1..$D7F9: Result := 'z';
else
Result := Char(32);
end;
end;
var
i: Integer;
C: Char;
PYStr:string;
begin
PYStr := '';
i := 1;
while i <= Length(aChinese) do
begin
if aChinese[i] <= Chr(127) then
begin
if aIsCapital then
PYStr := PYStr + UpCase(aChinese[i])
else
PYStr := PYStr + aChinese[i];
i := i + 1;
end
else
begin
C := GetPYIndexChar(Copy(aChinese, i, 2));
if C <> Char(32) then
if aIsCapital then
PYStr := PYStr + UpCase(C)
else
PYStr := PYStr + C;
i := i + 2;
end;
end;
Result:=PYStr;
end;