Search code examples
delphiarabic

how to detect arabic input in TDBEdit


I have TDBEdit how I forced the user to write in Arabic only

How To Detect Arabic Input in (TDBEdit) in Delphi ?


Solution

  • Using the article Tom mentioned you can achieve what you want:

    The article: Arabic blocks in Unicode.

    Check for the following inputs

    procedure TForm8.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      Caption := 'arabic';
      case integer(key) of
        1536..1791,1872..1919,2208..2303,-1200..-513,-400..-257,8,32,48..57:
           begin
           end;
      else
        // intervene here by setting key = #0
        Caption :=key+ ': is not an arabic character';
    end; 
    

    The numbers above are the decimal representation of the HEX values in the article.