http://www.devart.com/forums/viewtopic.php?t=19735
Thanks for the new version for fixing Unicode issue. However, there is new problem and shortcoming :
1. Blob Field Backup is problematic when using both HexBlob or not
2. The file size is doubled as the current encoding is utf16
I skipped the demo code in that post as the problem is partially solved (as below) and they have long line that cause the format disaster.
Regarding Blob Field Backup, I think I had find a fix in HexBlob mode. The problem is that the code is still using PAnsiChar Typecast which should be PWideChar for VER12P.
Code: Select all
MyService.TCustomMyDumpProcessor.BackupObjects's
Sub Procedure ProcessField Line 1641
change
PAnsiChar(Integer(SValue) + sbOffset), Piece.Used);
to
{$IFDEF VER12P}PWideChar{$ELSE}PAnsiChar{$ENDIF}(Integer(SValue) + sbOffset), Piece.Used);
and the generated result is OK.
I still don't know how to fix the problem if HexBlob mode is false.
Also, I had many blob fields which actually has strings and I see that that procedure also change those strings to Hex is make the file even larger. It is not critical though as at least it work.
Regarding using utf8 to reduce file size, I can make it work successfully. The resulting file size is slightly over 50% of using Unicode.
For my modification, Backup part is easy and straight forward :
Code: Select all
MyService.TCustomMyDumpProcessor.Backup
Change
s := #$FF#$FE;
to
s := #$EF#$BB#$BF;
MyService.TCustomMyDumpProcessor.Add
Change
buf := Encoding.Unicode.GetBytes(WideString(Line + #$D#$A));
to
buf := Encoding.UTF8.GetBytes(UTF8Encode(Line + #$D#$A));
For Restore, I make the following change initially and it work in restoring the backup.
Code: Select all
DAScript.TDAScriptProcessor.CreateParser
Line 400 Change
enc := Encoding.Default;
to
enc := Encoding.UTF8;
However, it cause a index out of range error after the successful restore. With a closer look, the TParser take the stream size as TextLength but those multiple bytes char length 1 in FBlockSize but actually take more then 1 bytes. So, at the end, TextLength is bigger then FBlockSize and the Parser ReadNextBlock (reading nothing) and finally read from the empty buffer and cause index out of range.
So I make the following change :
Code: Select all
CRParser.TParser.ReadNextBlock;
Line 1076 Add
if Size FBlockSize then // i.e. Variable Length char included
TextLength := TextLength - (Size - FBlockSize);