mORMot and Open Source friends
Check-in [4e8cd5a87a]
Not logged in

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

Overview
Comment:fixed process with Unicode content for mORMotVCL unit
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4e8cd5a87a459140b95ba88fef2fffdb511de74c
User & Date: ab 2013-04-21 07:41:00
Context
2013-04-21
07:55
TSQLDBStatement.ColumnToVariant() will now handle VariantStringAsWideString property as expected check-in: 289abf2e86 user: ab tags: trunk
07:41
fixed process with Unicode content for mORMotVCL unit check-in: 4e8cd5a87a user: ab tags: trunk
2013-04-20
11:16
introduce new TRC4 object for RC4 encryption algorithm (this implementation should be faster than other Delphi versions around, especially at key initialization) check-in: 4962cf790c user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite3/mORMotVCL.pas.

45
46
47
48
49
50
51

52
53
54
55
56
57
58
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
  Version 1.17
  - first public release, corresponding to Synopse mORMot Framework 1.17
  
  Version 1.18
  - renamed SQLite3VCL.pas to mORMotVCL.pas
  - fixed ticket [9de8be5d9e] with some types like TEnumeration or TTimeLog

  - introduced new aForceWideString optional parameter for ticket [2970335e40]

}

{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER

interface
................................................................................
      sftFloat, sftCurrency:
        result.Fields[F].AsFloat := GetExtended(aTable.Get(i,F));
      sftID:
        result.Fields[F].AsInteger := aTable.GetAsInteger(i,F);
      sftEnumerate, sftSet:
        if Types[F].EnumType=nil then
          result.Fields[F].AsInteger := aTable.GetAsInteger(i,F) else
          result.Fields[F].AsString := aTable.GetS(i,F);
      sftDateTime:
        result.Fields[F].AsDateTime := Iso8601ToDateTimePUTF8Char(aTable.Get(i,F),0);
      sftTimeLog, sftModTime, sftCreateTime:
        result.Fields[F].AsDateTime := aTable.GetVariant(i,F,aClient);
      sftBlob:
        {$ifdef UNICODE}
        result.Fields[F].AsBytes := aTable.GetBytes(i,F);
................................................................................
        result.Fields[F].AsString := aTable.GetBlob(i,F);
        {$endif}
      sftUTF8Text:
        {$ifndef UNICODE}
        if aForceWideString then
          (result.Fields[F] as TWideStringField).Value := aTable.GetSynUnicode(i,F) else
        {$endif}
          result.Fields[F].AsString := aTable.GetS(i,F);
      else   
        result.Fields[F].AsVariant := aTable.GetVariant(i,F,aClient);
      end;
      result.Post;
    end;
    result.First;
  except






>







 







|







 







|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  Version 1.17
  - first public release, corresponding to Synopse mORMot Framework 1.17
  
  Version 1.18
  - renamed SQLite3VCL.pas to mORMotVCL.pas
  - fixed ticket [9de8be5d9e] with some types like TEnumeration or TTimeLog
  - fixed process with Unicode content
  - introduced new aForceWideString optional parameter for ticket [2970335e40]

}

{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER

interface
................................................................................
      sftFloat, sftCurrency:
        result.Fields[F].AsFloat := GetExtended(aTable.Get(i,F));
      sftID:
        result.Fields[F].AsInteger := aTable.GetAsInteger(i,F);
      sftEnumerate, sftSet:
        if Types[F].EnumType=nil then
          result.Fields[F].AsInteger := aTable.GetAsInteger(i,F) else
          result.Fields[F].AsString := aTable.GetString(i,F);
      sftDateTime:
        result.Fields[F].AsDateTime := Iso8601ToDateTimePUTF8Char(aTable.Get(i,F),0);
      sftTimeLog, sftModTime, sftCreateTime:
        result.Fields[F].AsDateTime := aTable.GetVariant(i,F,aClient);
      sftBlob:
        {$ifdef UNICODE}
        result.Fields[F].AsBytes := aTable.GetBytes(i,F);
................................................................................
        result.Fields[F].AsString := aTable.GetBlob(i,F);
        {$endif}
      sftUTF8Text:
        {$ifndef UNICODE}
        if aForceWideString then
          (result.Fields[F] as TWideStringField).Value := aTable.GetSynUnicode(i,F) else
        {$endif}
          result.Fields[F].AsString := aTable.GetString(i,F);
      else   
        result.Fields[F].AsVariant := aTable.GetVariant(i,F,aClient);
      end;
      result.Post;
    end;
    result.First;
  except

Changes to SynCommons.pas.

9353
9354
9355
9356
9357
9358
9359
9360

9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371

9372
9373
9374
9375
9376
9377
9378
end;

function UTF8DecodeToUnicodeString(P: PUTF8Char; L: integer): UnicodeString; 
begin
  UTF8DecodeToUnicodeString(P,L,result);
end;

procedure UTF8DecodeToUnicodeString(P: PUTF8Char; L: integer; var result: UnicodeString); 

var L2: integer;
begin
  result := ''; // somewhat faster if result is freed before any SetLength()
  if L=0 then
    L := StrLen(P);
  if L=0 then
    exit;
  SetString(result,nil,L); // maximum posible unicode size (if all <#128)
  L2 := UTF8ToWideChar(pointer(result),P,L) shr 1;
  if L2<>L then
    SetLength(result,L2);

end;

function WinAnsiToUnicodeString(WinAnsi: PAnsiChar; WinAnsiLen: integer): UnicodeString;
begin
  SetString(result,nil,WinAnsiLen);
  WinAnsiConvert.AnsiBufferToUnicode(pointer(result),WinAnsi,WinAnsiLen);
end;






|
>
|

<
|
|
<
<
|
|
|
|
>







9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363

9364
9365


9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
end;

function UTF8DecodeToUnicodeString(P: PUTF8Char; L: integer): UnicodeString; 
begin
  UTF8DecodeToUnicodeString(P,L,result);
end;

procedure UTF8DecodeToUnicodeString(P: PUTF8Char; L: integer; var result: UnicodeString);
var short: array[byte] of WideChar;
    L2: integer;
begin

  if L<sizeof(short)shr 1 then
    SetString(result,short,UTF8ToWideChar(short,P,L) shr 1) else begin


    SetString(result,nil,L); // maximum posible unicode size (if all <#128)
    L2 := UTF8ToWideChar(pointer(result),P,L) shr 1;
    if L2<>L then
      SetLength(result,L2);
  end;
end;

function WinAnsiToUnicodeString(WinAnsi: PAnsiChar; WinAnsiLen: integer): UnicodeString;
begin
  SetString(result,nil,WinAnsiLen);
  WinAnsiConvert.AnsiBufferToUnicode(pointer(result),WinAnsi,WinAnsiLen);
end;