uuchar.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 2011 by the Free Pascal development team
  4. This unit redefines the Char type from ansichar into widechar
  5. See the file COPYING.FPC, included in this distribution,
  6. For details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit uuchar;
  12. interface
  13. type
  14. char = widechar;
  15. pchar = pwidechar;
  16. Function ParamStr(Param : Integer) : UnicodeString;
  17. implementation
  18. {$if defined(FPC_HAS_FEATURE_COMMANDARGS) }
  19. Function ParamStr(Param : Integer) : unicodestring;
  20. Var Len : longint;
  21. s : ansistring;
  22. begin
  23. {
  24. Paramstr(0) should return the name of the binary.
  25. Since this functionality is included in the system unit,
  26. we fetch it from there.
  27. Normally, pathnames are less than 255 chars anyway,
  28. so this will work correct in 99% of all cases.
  29. In time, the system unit should get a GetExeName call.
  30. }
  31. if (Param=0) then
  32. Paramstr:=System.Paramstr(0)
  33. else if (Param>0) and (Param<argc) then
  34. begin
  35. Len:=0;
  36. While Argv[Param][Len]<>#0 do
  37. Inc(len);
  38. SetLength(s,Len);
  39. If Len>0 then
  40. Move(Argv[Param][0],s[1],Len);
  41. paramstr:=s;
  42. end
  43. else
  44. paramstr:='';
  45. end;
  46. {$endif FPC_HAS_FEATURE_COMMANDARGS}
  47. end.