Need convert to ANSI !
Posted: Tue Feb 01, 2011 10:38 am
Hi !
I made an application, a text editor which uses SRichViewEdit component ( v3.2), with RTFReadProperties.UnicodeMode = rvruNoUnicode.
Database connection: Firebird 2.1, ADO, IBProvider3 with unicode_mode = false. Charset of FB database is WIN1250.
I make a document with this text :"Hello World ! ", i save them into database, ( or i edit later the text). INSERT and UPDATE works both correct.
When i edit this document style ( font size set to 30 etc.) and save RVF into database, comes up an error:
"IB-native IN-parameter value create failed. Position 0. Write BLOB: Can't translate text from UNICODE to [WIN1250]"
How can i convert this full document to ANSI ?
Users can edit documents, copy+paste from older documents, etc., that's why i have to convert it first.
I made a converter by this article, but it thid'nt work for me:
http://www.trichview.com/forums/viewtopic.php?t=70
My converter's code:
This code never runs, because RVData.GetRVStyle.TextStyles[StyleNo].Unicode is always false:
When is save the RVF, it still contains unicode....
I made an application, a text editor which uses SRichViewEdit component ( v3.2), with RTFReadProperties.UnicodeMode = rvruNoUnicode.
Database connection: Firebird 2.1, ADO, IBProvider3 with unicode_mode = false. Charset of FB database is WIN1250.
I make a document with this text :"Hello World ! ", i save them into database, ( or i edit later the text). INSERT and UPDATE works both correct.
When i edit this document style ( font size set to 30 etc.) and save RVF into database, comes up an error:
"IB-native IN-parameter value create failed. Position 0. Write BLOB: Can't translate text from UNICODE to [WIN1250]"
How can i convert this full document to ANSI ?
Users can edit documents, copy+paste from older documents, etc., that's why i have to convert it first.
I made a converter by this article, but it thid'nt work for me:
http://www.trichview.com/forums/viewtopic.php?t=70
My converter's code:
Code: Select all
procedure ConvertToANSI(rv: TCustomRichView);
var i: Integer;
begin
ConvertRVToANSI(rv.RVData);
for i := 0 to rv.Style.TextStyles.Count-1 do
rv.Style.TextStyles[i].Unicode := False;
end;
procedure ConvertRVToANSI(RVData: TCustomRVData);
var i,r,c, StyleNo: Integer;
table: TRVTableItemInfo;
begin
for i := 0 to RVData.ItemCount-1 do begin
StyleNo := RVData.GetItemStyle(i);
if StyleNo>=0 then begin
if RVData.GetRVStyle.TextStyles[StyleNo].Unicode then
begin
RVData.SetItemTextA(i, RVData.GetItemText(i));
RVData.GetItem(i).ItemOptions := RVData.GetItem(i).ItemOptions - [rvioUnicode];
end;
end
else if RVData.GetItemStyle(i)=rvsTable then begin
table := TRVTableItemInfo(RVData.GetItem(i));
for r := 0 to table.Rows.Count-1 do
for c := 0 to table.Rows[r].Count-1 do
if table.Cells[r,c]<>nil then
ConvertRVToANSI(table.Cells[r,c].GetRVData);
end;
end;
end;
Code: Select all
RVData.SetItemTextA(i, RVData.GetItemText(i));
RVData.GetItem(i).ItemOptions := RVData.GetItem(i).ItemOptions - [rvioUnicode];