Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 392
Miguel E Avatar asked Apr 10 '12 21:04

Miguel E


2 Answers

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.

like image 192
gonutz Avatar answered Oct 22 '22 06:10

gonutz


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

like image 37
RRUZ Avatar answered Oct 22 '22 06:10

RRUZ