function fGetUniCodeNumber(GB:string):Integer; var //计算Unicode编码,代码可能不太好, 希望大侠指出更好方法, i,j,k:integer; a:array[1..20] of Char; begin Result:=0;
StringToWideChar(GB,@(a[1]),10); i:=1; while ((a[i] <> #0) or (a[i+1] <> #0)) do begin j:=Integer(a[i]); k:=Integer(a[i+1]); Result:=k*$100+j; Exit; end; end;
function fExistsEmojiChar(sUnicodeText:UnicodeString):Boolean; var i,iResult:Integer; begin Result:=False; for i:=1 to Length(sUnicodeText) do begin iResult:=fGetUniCodeNumber(Copy(sUnicodeText,i,1)); //这个范围是大致的, 具体肯定不对,但也好像差不多管用 //我不太懂原理, 瞎懵的代码, 希望有大侠斧正 if (iResult>=55000) and (iResult<=59000) then begin Result:=True; Exit; end; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin if fExistsEmojiChar(Memo1.Text) then begin showmessage('有表情符号在内(fmx.andoird下测试还凑合着用)'); end; end;
----------------------------------------------
...