Search code examples
delphidelphi-xe

Check if character is letter in Delphi (Unicode)


Are there pre-defined character sets 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 does this cover characters with diacritics like Á, À, Ú, É, etc., too?

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


Solution

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