From: Andr? S. <asn...@us...> - 2004-05-31 18:08:56
|
Update of /cvsroot/jvcl/dev/JVCL3/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24417/JVCL3/qcommon Modified Files: JvQConsts.pas JvQFinalize.pas JvQWStrUtils.pas Log Message: Updated Index: JvQWStrUtils.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/qcommon/JvQWStrUtils.pas,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** JvQWStrUtils.pas 26 May 2004 11:44:05 -0000 1.8 --- JvQWStrUtils.pas 31 May 2004 18:08:44 -0000 1.9 *************** *** 50,54 **** ); TWideFileOptions = set of TWideFileOptionsType; ! TSearchFlag = ( sfCaseSensitive, // match letter case --- 50,54 ---- ); TWideFileOptions = set of TWideFileOptionsType; ! TSearchFlag = ( sfCaseSensitive, // match letter case *************** *** 58,64 **** sfWholeWordOnly // match only text at end/start and/or surrounded by white spaces ); ! TSearchFlags = set of TSearchFlag; TWStrings = class; TWStringList = class; --- 58,79 ---- sfWholeWordOnly // match only text at end/start and/or surrounded by white spaces ); ! TSearchFlags = set of TSearchFlag; + // UTF conversion schemes (UCS) data types + PUCS4 = ^UCS4; + UCS4 = Cardinal; + PUCS2 = PWideChar; + UCS2 = WideChar; + + TUCS2Array = array of UCS2; + TUCS4Array = array of UCS4; + const + ReplacementCharacter: UCS4 = $0000FFFD; + MaximumUCS2: UCS4 = $0000FFFF; + MaximumUTF16: UCS4 = $0010FFFF; + MaximumUCS4: UCS4 = $7FFFFFFF; + + type TWStrings = class; TWStringList = class; *************** *** 267,270 **** --- 282,365 ---- end; + const + HalfShift: Integer = 10; + + HalfBase: UCS4 = $0010000; + HalfMask: UCS4 = $3FF; + + OffsetsFromUTF8: array[0..5] of UCS4 = ($00000000, $00003080, $000E2080, + $03C82080, $FA082080, $82082080); + + BytesFromUTF8: array[0..255] of Byte = ( + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5); + + FirstByteMark: array[0..6] of Byte = ($00, $00, $C0, $E0, $F0, $F8, $FC); + + function WideStringToUTF8(S: WideString): AnsiString; + + var + Ch: UCS4; + L, J, T, + BytesToWrite: Cardinal; + ByteMask: UCS4; + ByteMark: UCS4; + + begin + if Length(S) = 0 then + Result := '' + else + begin + SetLength(Result, Length(S) * 6); // assume worst case + T := 1; + ByteMask := $BF; + ByteMark := $80; + + for J := 1 to Length(S) do + begin + Ch := UCS4(S[J]); + + if Ch < $80 then + BytesToWrite := 1 + else + if Ch < $800 then + BytesToWrite := 2 + else + if Ch < $10000 then + BytesToWrite := 3 + else + if Ch < $200000 then + BytesToWrite := 4 + else + if Ch < $4000000 then + BytesToWrite := 5 + else + if Ch <= MaximumUCS4 then + BytesToWrite := 6 + else + begin + BytesToWrite := 2; + Ch := ReplacementCharacter; + end; + + for L := BytesToWrite downto 2 do + begin + Result[T + L - 1] := Char((Ch or ByteMark) and ByteMask); + Ch := Ch shr 6; + end; + Result[T] := Char(Ch or FirstByteMark[BytesToWrite]); + Inc(T, BytesToWrite); + end; + SetLength(Result, T - 1); // set to actual length + end; + end; + + // WideChar functions Index: JvQConsts.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/qcommon/JvQConsts.pas,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** JvQConsts.pas 26 May 2004 11:44:05 -0000 1.10 --- JvQConsts.pas 31 May 2004 18:08:34 -0000 1.11 *************** *** 35,40 **** uses ! SysUtils, ! QControls, QGraphics; --- 35,39 ---- uses ! SysUtils, QControls, Types, QGraphics, QWindows; *************** *** 78,82 **** {$ENDIF MSWINDOWS} {$IFDEF LINUX} ! SDelphiKey = '.borland/.Jvcl3'; {$ENDIF} { JvDataProvider constants } --- 77,81 ---- {$ENDIF MSWINDOWS} {$IFDEF LINUX} ! SDelphiKey = '.borland/.jvclx1'; {$ENDIF} { JvDataProvider constants } Index: JvQFinalize.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/qcommon/JvQFinalize.pas,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** JvQFinalize.pas 26 May 2004 11:44:05 -0000 1.5 --- JvQFinalize.pas 31 May 2004 18:08:44 -0000 1.6 *************** *** 60,64 **** /// Only global variables are allowed to be specified. /// </limitation> ! function AddFinalizeObjectNil(const UnitName: string; var Reference: TObject): TObject; /// <summary> --- 60,64 ---- /// Only global variables are allowed to be specified. /// </limitation> ! function AddFinalizeObjectNil(const UnitName: string; var Reference{: TObject}): TObject; /// <summary> *************** *** 69,73 **** /// Only global variables are allowed to be specified. /// </limitation> ! function AddFinalizeFreeAndNil(const UnitName: string; var Reference: TObject): TObject; /// <summary> --- 69,73 ---- /// Only global variables are allowed to be specified. /// </limitation> ! function AddFinalizeFreeAndNil(const UnitName: string; var Reference{: TObject}): TObject; /// <summary> *************** *** 84,88 **** /// Only global variables are allowed to be specified. /// </limitation> ! function AddFinalizeMemoryNil(const UnitName: string; var Ptr: Pointer): Pointer; --- 84,88 ---- /// Only global variables are allowed to be specified. /// </limitation> ! function AddFinalizeMemoryNil(const UnitName: string; var Ptr{: Pointer}): Pointer; *************** *** 379,392 **** end; ! function AddFinalizeObjectNil(const UnitName: string; var Reference: TObject): TObject; begin ! TFinalizeObjectNilItem.Create(UnitName, Reference); ! Result := Reference; end; ! function AddFinalizeFreeAndNil(const UnitName: string; var Reference: TObject): TObject; begin ! TFinalizeFreeAndNilItem.Create(UnitName, Reference); ! Result := Reference; end; --- 379,392 ---- end; ! function AddFinalizeObjectNil(const UnitName: string; var Reference{: TObject}): TObject; begin ! TFinalizeObjectNilItem.Create(UnitName, TObject(Reference)); ! Result := TObject(Reference); end; ! function AddFinalizeFreeAndNil(const UnitName: string; var Reference{: TObject}): TObject; begin ! TFinalizeFreeAndNilItem.Create(UnitName, TObject(Reference)); ! Result := TObject(Reference); end; *************** *** 397,404 **** end; ! function AddFinalizeMemoryNil(const UnitName: string; var Ptr: Pointer): Pointer; begin ! TFinalizeMemoryNilItem.Create(UnitName, Ptr); ! Result := Ptr; end; --- 397,404 ---- end; ! function AddFinalizeMemoryNil(const UnitName: string; var Ptr{: Pointer}): Pointer; begin ! TFinalizeMemoryNilItem.Create(UnitName, Pointer(Ptr)); ! Result := Pointer(Ptr); end; |