View Issue Details

IDProjectCategoryView StatusLast Update
0036264PackagesLazReportpublic2019-11-06 19:08
ReporterMichal Gawrycki Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Summary0036264: TfrCustomMemoView - Do not convert code page when loading lines from a blob field
DescriptionCurrently, code page conversion is performed when loading data from a blob field. This causes problems under operating systems where code page is not UTF8 (like Windows).
Patch attached.
TagsNo tags attached.
Fixed in Revisionr62206
LazTarget-
Widgetset
Attached Files

Relationships

related to 0036094 closedJuha Manninen Lazarus Undoing visual control deletion cause captions transcoding 

Activities

Michal Gawrycki

2019-11-05 17:30

reporter  

lr_class_blob.patch (837 bytes)   
Index: components/lazreport/source/lr_class.pas
===================================================================
--- components/lazreport/source/lr_class.pas	(revision 61904)
+++ components/lazreport/source/lr_class.pas	(working copy)
@@ -4745,23 +4745,8 @@
 end;
 
 procedure TfrCustomMemoView.GetBlob(b: TfrTField);
-var
-  M: TMemoryStream;
 begin
-  // todo: TBLobField.AssignTo is not implemented yet
-  //       even if I supply a patch for 2.0.4 it will
-  //       not be integrated because it's in RC1 now
-  //       (I guess)
-  //
-  //Memo1.Assign(b);
-  M := TMemoryStream.Create;
-  try
-    TBlobField(B).SaveToStream(M);
-    M.Position := 0;
-    Memo1.LoadFromStream(M);
-  finally
-    M.Free;
-  end;
+  Memo1.Text := TBlobField(b).AsString;
 end;
 
 procedure TfrCustomMemoView.FontChange(sender: TObject);
lr_class_blob.patch (837 bytes)   

Juha Manninen

2019-11-06 07:51

developer   ~0119092

I don't understand the issue. In the original code, how would SaveToStream() + LoadFromStream() convert a code page?
Your new code is cleaner in any case of course.

Michal Gawrycki

2019-11-06 10:10

reporter   ~0119093

If you look at the implementation of TStrings.LoadFromStream (Stream) you will see that it calls the method TStrings.LoadFromStream (Stream, IgnoreEncoding = false), which calls the method TStrings.LoadFromStream (Stream, TEncoding = nil) and this converts the code page.
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/objpas/classes/stringl.inc?revision=43365&view=markup#l1299

Juha Manninen

2019-11-06 15:22

developer   ~0119102

Ok, you probably compiled with FPC trunk. There was a change in TStrings affecting encoding indeed.
I applied your patch. Thanks.

Michal Gawrycki

2019-11-06 19:08

reporter   ~0119108

I forgot to mention that I'm using trunk version. Thanks. Closed.

Issue History

Date Modified Username Field Change
2019-11-05 17:30 Michal Gawrycki New Issue
2019-11-05 17:30 Michal Gawrycki File Added: lr_class_blob.patch
2019-11-06 07:51 Juha Manninen Note Added: 0119092
2019-11-06 10:10 Michal Gawrycki Note Added: 0119093
2019-11-06 15:14 Juha Manninen Relationship added related to 0036094
2019-11-06 15:16 Juha Manninen Assigned To => Juha Manninen
2019-11-06 15:16 Juha Manninen Status new => assigned
2019-11-06 15:22 Juha Manninen Status assigned => resolved
2019-11-06 15:22 Juha Manninen Resolution open => fixed
2019-11-06 15:22 Juha Manninen Fixed in Revision => r62206
2019-11-06 15:22 Juha Manninen LazTarget => -
2019-11-06 15:22 Juha Manninen Note Added: 0119102
2019-11-06 19:08 Michal Gawrycki Status resolved => closed
2019-11-06 19:08 Michal Gawrycki Note Added: 0119108