sysunix.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 2001 by the Free Pascal development team
  4. This file contains the OS independent routines of the system unit
  5. for unix styled systems
  6. See the File COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$I system.inc}
  13. {$i winiconv.inc}
  14. function get_locale_charset: AnsiString;
  15. var
  16. p: SizeInt;
  17. begin
  18. // Get one of non-empty environment variables in the next order:
  19. // LC_ALL, LC_CTYPE, LANG. Default is 'ASCII'.
  20. Result:=FpGetEnv('LC_ALL');
  21. if Result='' then
  22. Result:=FpGetEnv('LC_CTYPE');
  23. if Result='' then
  24. Result:=FpGetEnv('LANG');
  25. if Result='' then
  26. Result:='ASCII'
  27. else begin
  28. // clean up, for example en_US.UTF-8 => UTF-8
  29. p:=Pos('.',Result);
  30. if p>0 then Delete(Result,1,p);
  31. p:=Pos('@',Result);
  32. if p>0 then Delete(Result,p,length(Result)-p+1);
  33. end;
  34. end;
  35. procedure InitUnixStrings;
  36. begin
  37. DefaultSystemCodepage:=iconv2win(get_locale_charset);
  38. initunicodestringmanager;
  39. end;