mORMot and Open Source friends
Check-in [67711926bf]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{4430} fix system code page support on FPC / Linux
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 67711926bf2d907a82e068d82bc81fdd3c0dd2cd
User & Date: ab 2018-03-14 15:36:42
Context
2018-03-14
15:39
{4431} ensure SynDBOracle will use NLS_LANG on all platforms check-in: 98383d8297 user: ab tags: trunk
15:36
{4430} fix system code page support on FPC / Linux check-in: 67711926bf user: ab tags: trunk
14:39
{4429} small documentation enhancements (especially FAQ) about User-Agent and unquoted JSON fields check-in: 5cdae72611 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SynCommons.pas.

826
827
828
829
830
831
832
833
834
835
836



837
838
839
840
841
842
843
.....
18244
18245
18246
18247
18248
18249
18250



18251
18252
18253
18254
18255
18256
18257
.....
64674
64675
64676
64677
64678
64679
64680



64681
64682
64683
64684
64685
64686
64687
64688
64689
64690
.....
64696
64697
64698
64699
64700
64701
64702
64703
64704
64705
64706
64707
64708
64709
64710
64711
64712
64713
64714
64715
64716
64717
64718
64719
64720
  /// US English Windows Code Page, i.e. WinAnsi standard character encoding
  CODEPAGE_US = 1252;

  /// Latin-1 ISO/IEC 8859-1 Code Page
  CODEPAGE_LATIN1 = 819;

{$ifndef MSWINDOWS}
  /// estimate the system code page is WinAnsi
  GetACP = CODEPAGE_US;
  /// internal Code Page for UTF-8 Unicode encoding
  CP_UTF8 = 65001;



{$endif}

{$ifdef FPC} { make cross-compiler and cross-CPU types available to Delphi }

type
  PBoolean = ^Boolean;

................................................................................
  {$ifndef MSWINDOWS}
    {$ifdef FPCUSEVERSIONINFO} // should be enabled in Synopse.inc
    fileinfo, // FPC 3.0 and up
    winpeimagereader, // winpe exe info
    elfreader,  // ELF executables
    machoreader, // MACH-O executables
    {$endif FPCUSEVERSIONINFO}



  {$endif MSWINDOWS}
  SynFPCTypInfo, // small wrapper unit around FPC's TypInfo.pp
  TypInfo,
  StrUtils;
{$endif FPC}


................................................................................
  JSON_CONTENT_TYPE_VAR := JSON_CONTENT_TYPE;
  JSON_CONTENT_TYPE_HEADER_VAR := JSON_CONTENT_TYPE_HEADER;
  NULL_STR_VAR := 'null';
  SetLength(JSON_SQLDATE_MAGIC_TEXT,3);
  PCardinal(pointer(JSON_SQLDATE_MAGIC_TEXT))^ := JSON_SQLDATE_MAGIC;
  {$ifdef FPC}
  {$ifdef ISFPC27}



  SetMultiByteConversionCodePage(CP_UTF8);
  SetMultiByteRTLFileSystemCodePage(CP_UTF8);
  {$endif}
  {$endif FPC}
  {$ifdef KYLIX3}
  // if default locale is set to *.UTF-8, which is the case in most modern
  // linux default configuration, unicode decode will fail in SysUtils.CheckLocale
  setlocale(LC_CTYPE,'en_US'); // force locale for a UTF-8 server
  {$endif}
{$ifndef EXTENDEDTOSTRING_USESTR}
................................................................................
  SettingsUS.DecimalSeparator := '.'; // value may have been overriden :(
{$endif}
  for i := 0 to 255 do
    NormToNormByte[i] := i;
  NormToUpperAnsi7Byte := NormToNormByte;
  for i := ord('a') to ord('z') do
    dec(NormToUpperAnsi7Byte[i],32);
{$ifdef OWNNORMTOUPPER}
  // initialize custom NormToUpper[] and NormToLower[] arrays
  MoveFast(NormToUpperAnsi7,NormToUpper,138);
  MoveFast(n2u,NormToUpperByte[138],SizeOf(n2u));
  for i := 0 to 255 do begin
    d := NormToUpperByte[i];
    if d in [ord('A')..ord('Z')] then
      inc(d,32);
    NormToLowerByte[i] := d;
  end;
{$endif OWNNORMTOUPPER}
  // code below is 55 bytes long, therefore shorter than a const array
  FillcharFast(ConvertHexToBin[0],SizeOf(ConvertHexToBin),255); // all to 255
  v := 0;
  for i := ord('0') to ord('9') do begin
    ConvertHexToBin[i] := v;
    inc(v);
  end;






<
<


>
>
>







 







>
>
>







 







>
>
>


|







 







|









|







826
827
828
829
830
831
832


833
834
835
836
837
838
839
840
841
842
843
844
.....
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
.....
64678
64679
64680
64681
64682
64683
64684
64685
64686
64687
64688
64689
64690
64691
64692
64693
64694
64695
64696
64697
.....
64703
64704
64705
64706
64707
64708
64709
64710
64711
64712
64713
64714
64715
64716
64717
64718
64719
64720
64721
64722
64723
64724
64725
64726
64727
  /// US English Windows Code Page, i.e. WinAnsi standard character encoding
  CODEPAGE_US = 1252;

  /// Latin-1 ISO/IEC 8859-1 Code Page
  CODEPAGE_LATIN1 = 819;

{$ifndef MSWINDOWS}


  /// internal Code Page for UTF-8 Unicode encoding
  CP_UTF8 = 65001;
var
  /// contains the curent system code page (default WinAnsi)
  GetACP: integer = CODEPAGE_US;
{$endif}

{$ifdef FPC} { make cross-compiler and cross-CPU types available to Delphi }

type
  PBoolean = ^Boolean;

................................................................................
  {$ifndef MSWINDOWS}
    {$ifdef FPCUSEVERSIONINFO} // should be enabled in Synopse.inc
    fileinfo, // FPC 3.0 and up
    winpeimagereader, // winpe exe info
    elfreader,  // ELF executables
    machoreader, // MACH-O executables
    {$endif FPCUSEVERSIONINFO}
    {$ifdef ISFPC271}
    unixcp,
    {$endif}
  {$endif MSWINDOWS}
  SynFPCTypInfo, // small wrapper unit around FPC's TypInfo.pp
  TypInfo,
  StrUtils;
{$endif FPC}


................................................................................
  JSON_CONTENT_TYPE_VAR := JSON_CONTENT_TYPE;
  JSON_CONTENT_TYPE_HEADER_VAR := JSON_CONTENT_TYPE_HEADER;
  NULL_STR_VAR := 'null';
  SetLength(JSON_SQLDATE_MAGIC_TEXT,3);
  PCardinal(pointer(JSON_SQLDATE_MAGIC_TEXT))^ := JSON_SQLDATE_MAGIC;
  {$ifdef FPC}
  {$ifdef ISFPC27}
  {$ifndef MSWINDOWS}
  GetACP := GetSystemCodePage;
  {$endif MSWINDOWS}
  SetMultiByteConversionCodePage(CP_UTF8);
  SetMultiByteRTLFileSystemCodePage(CP_UTF8);
  {$endif ISFPC27}
  {$endif FPC}
  {$ifdef KYLIX3}
  // if default locale is set to *.UTF-8, which is the case in most modern
  // linux default configuration, unicode decode will fail in SysUtils.CheckLocale
  setlocale(LC_CTYPE,'en_US'); // force locale for a UTF-8 server
  {$endif}
{$ifndef EXTENDEDTOSTRING_USESTR}
................................................................................
  SettingsUS.DecimalSeparator := '.'; // value may have been overriden :(
{$endif}
  for i := 0 to 255 do
    NormToNormByte[i] := i;
  NormToUpperAnsi7Byte := NormToNormByte;
  for i := ord('a') to ord('z') do
    dec(NormToUpperAnsi7Byte[i],32);
  {$ifdef OWNNORMTOUPPER}
  // initialize custom NormToUpper[] and NormToLower[] arrays
  MoveFast(NormToUpperAnsi7,NormToUpper,138);
  MoveFast(n2u,NormToUpperByte[138],SizeOf(n2u));
  for i := 0 to 255 do begin
    d := NormToUpperByte[i];
    if d in [ord('A')..ord('Z')] then
      inc(d,32);
    NormToLowerByte[i] := d;
  end;
  {$endif OWNNORMTOUPPER}
  // code below is 55 bytes long, therefore shorter than a const array
  FillcharFast(ConvertHexToBin[0],SizeOf(ConvertHexToBin),255); // all to 255
  v := 0;
  for i := ord('0') to ord('9') do begin
    ConvertHexToBin[i] := v;
    inc(v);
  end;

Changes to SynopseCommit.inc.

1
'1.18.4429'
|
1
'1.18.4430'