There is a database on firebird3. The program writes data from a file or from memo to blob and back to read from blob to memo. There are 2 blob fields in the database : blob_Binary (subtype = 0) and Blob_Text (subtype = 1, utf-8). Encoding and in the connection string to the database and tables - Utf-8
There are the following problems of preserving the Russian and Georgian letters.
1) saving data to blob from memo.
If so then nothing is saved !!!:
var ms : TMemoryStream; begin ms := TMemoryStream.Create; try memo1.lines.savetostream(ms); ms.position := 0; Query1.Close; Query1.SQL.Text:='insert into content(Blob_text) values(:Blob_text)'; Query1.ParamByName('Blob_text').LoadFromStream(ms, ftunknown); Query1.ExecSQL; finally ms.free; end; and with the help of a stringlist in binary blob-e is incorrectly saved (English and Russian texts are adequately preserved, and instead of Georgian letters displays question marks)
111 Hello Hello ??????
var sl :TStringList; begin sl := TStringList.Create; try sl.Text := Memo1.Text; Query1.Edit; Query1.FieldByName('blob_Binary').Assign(sl); Query1.Post; finally sl.Free; end; And if you use streams then I also see question marks instead of Georgian letters
var i:integer; blobF : TBlobField; ms : TMemoryStream; begin ms := TMemoryStream.Create; try memo1.lines.savetostream(ms); ms.position := 0; Query1.Edit; TBlobField(Query1.FieldByName('BLOB_BINARY')).LoadFromStream(ms); Query1.Post; Query1.ApplyUpdates; finally ms.free; end; Query1.Close; Query1.SQL.Text:='select * from content order by content_id'; query1.Open(); 2) saving to blob from a text file (the English text is correctly preserved, but the Russians and the Georgian are not):
ID:=Query1.FieldByName('Content_id').asInteger; OpenDialog1.Execute; Query1.Close; Query1.SQL.Text := 'SELECT * FROM content where Content_id=:id'; Query1.Params[0].AsInteger:=ID; Query1.open; Query1.Edit; (Query1.FieldByName('Blob_Binary') as TBlobField).LoadFromFile(OpenDialog1.FileName); Query1.Post; 3) Open in memo :
var ms : TMemoryStream; begin ms := TMemoryStream.Create; try TBlobField(Query1.FieldByName('Blob_Binary')).SaveToStream(ms); //or Blob_Text ms.position := 0; memo1.lines.loadfromstream(ms); finally ms.free; end; Result: "1111 Hello i? eaao" is output from the binary blob, and only the first letter of the text, "1", is output from the text:
or from blob-s in memo1 and memo2 are displayed correctly though, as clearly from dbMemo1 and dbMemo2, hieroglyphs are saved in the database:
4) IBExpert:
Update content set Blob_Binary='hello ΠΏΡΠΈΠ²Π΅Ρ ααααα α―ααα',Blob_Text='hello ΠΏΡΠΈΠ²Π΅Ρ ααααα α―ααα' where content_id=... writes in binary blob-e krakozyabry on the place of Russian and Georgian letters, and in text it is all right.



