Miguel E
Miguel E

Reputation: 1326

Check if character is letter in Delphi (Unicode)

Are there pre-defined charsets in Delphi, to check if a character is a letter?

In Cocoa I use something like

if ([[NSCharacterSet whitespaceCharacterSet] characterIsMember:character])

I know I can do in Delphi

if c in ['A'..'Z'] then

but will this cover foreign accentuated characters like Á, À, Ú, É, ....?

What would be the most efficient way to check this in Delphi. I need to check if a string is fully composed with letters.

Upvotes: 12

Views: 12028

Answers (2)

gonutz
gonutz

Reputation: 5582

On Rad Studio XE4 I am told that TCharacter is deprecated and to use System.Character.TCharHelper instead. It is a record helper that extends type Char with functions in method syntax. This means that I now add System.Character to my uses list and can then call e.g. C.IsLetterOrDigit where C is of type Char.

Upvotes: 2

RRUZ
RRUZ

Reputation: 136391

Try using the Character.TCharacter.IsLetter or Character.IsLetter functions

Upvotes: 19

Related Questions