tisnumber2.pp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. program tisnumber2;
  2. {$ifdef FPC}
  3. {$mode objfpc}
  4. {$H+}
  5. {$PACKENUM 1}
  6. {$endif fpc}
  7. {$ifndef FPC}
  8. {$APPTYPE CONSOLE}
  9. {$endif}
  10. uses
  11. SysUtils,
  12. character;
  13. {$ifndef FPC}
  14. type UnicodeChar = WideChar;
  15. {$endif}
  16. procedure DoError(ACode : Integer); overload;
  17. begin
  18. WriteLn('Error #',ACode);
  19. Halt(Acode);
  20. end;
  21. procedure DoError(ACode : Integer; ACodePoint : Integer); overload;
  22. begin
  23. WriteLn('Error #',ACode,' ; CodePoint = ',IntToHex(ACodePoint,4));
  24. Halt(Acode);
  25. end;
  26. procedure DoError(ACode : Integer; ACodePoint : UnicodeChar); overload;
  27. begin
  28. WriteLn('Error #',ACode,' ; CodePoint = ',IntToHex(Ord(ACodePoint),4));
  29. Halt(Acode);
  30. end;
  31. var
  32. e, i , k: Integer;
  33. strPrefix, uc : UnicodeString;
  34. locCharPos : Integer;
  35. d : Double;
  36. begin
  37. strPrefix := '012345AZERT ';
  38. locCharPos := Length(strPrefix) + 1;
  39. e := 1;
  40. k := 0;
  41. for i := Low(Word) to High(Word) do begin
  42. uc := strPrefix + UnicodeChar(i) + strPrefix;
  43. if TCharacter.IsNumber(uc,locCharPos) then begin
  44. WriteLn('CodePoint = ',IntToHex(Ord(uc[locCharPos]),4), ' ; IsNumber = ',TCharacter.IsNumber(uc,locCharPos));
  45. Inc(k);
  46. end;
  47. end;
  48. WriteLn(k, ' numbers',sLineBreak);
  49. Inc(e);
  50. for i := 0 to 9 do begin
  51. uc := strPrefix + IntToStr(i) + strPrefix;
  52. if not TCharacter.IsNumber(uc,locCharPos) then
  53. DoError(e,uc[locCharPos]);
  54. end;
  55. WriteLn('ok');
  56. end.