Judging whether there is Chinese in the string

xiaoxiao2021-03-06  67

System.text.Encoding.default.getbytecount (str) == Str.Length

For Chinese, otherwise there is Chinese

Delphi

Function Checken (Aen: String): Boolean;

VAR

ANS: ANSISTRING;

WIS: WIDESTRING;

I, ANSLNG, WISLNG: INTEGER

Begin

Result: = FALSE;

ANS: = ansistring (aen);

WIS: = WIDESTRING (AEN);

For i: = 1 to Length (aen) do

Begin

ANSLNG: = Length (ANS [i]);

WISLNG: = Length (ANSISTRING (Wis [I]));

IF ANSLNG <> WISLNG1 RESULT: = FALSE

Else if ORD (ANS [I]) <128 THEN

Begin

RESULT: = TRUE;

Break;

END;

END;

END;

转载请注明原文地址:https://www.9cbs.com/read-89690.html

New Post(0)