Clerk hello:
Excuse me, recently a lot of customer response, my ScaleRichView when using paste, if the Chinese content, paste it is garbled,
thank you
			
			
									
						
										
						Paste the Chinese is garbled
- 
				Sergey Tkachenko
- Site Admin
- Posts: 17952
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
- 
				Sergey Tkachenko
- Site Admin
- Posts: 17952
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I read your answer.
You use non-Unicode version of Delphi, so, by default, text in ScaleRichView content is not Unicode. TRichView and ScaleRichView require to be Unicode to handle Chinese text properly.
You copies text from MS Word, so, copying occurs in RTF format.
I suggest to call this code to convert content of TSRichViewEdit to Unicode:
Call ConvertSRVToUnicode to convert your TSRichViewEdit control to Unicode when the application starts. If your application loads RVF files, you need to call this function after loading as well.
If TSRichViewEdit is already displayed, call SRichViewEdit.Format after this procedure.
			
			
									
						
										
						You use non-Unicode version of Delphi, so, by default, text in ScaleRichView content is not Unicode. TRichView and ScaleRichView require to be Unicode to handle Chinese text properly.
You copies text from MS Word, so, copying occurs in RTF format.
I suggest to call this code to convert content of TSRichViewEdit to Unicode:
Code: Select all
procedure ConvertRVDataToUnicode(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 not RVData.GetRVStyle.TextStyles[StyleNo].Unicode then
      begin
        RVData.SetItemTextR(i, RVU_GetRawUnicode(RVData.GetItemTextW(i)));
        Include(RVData.GetItem(i).ItemOptions, rvioUnicode);
      end;
    end
    else if RVData.GetItem(i) is TRVTableItemInfo 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
            ConvertRVDataToUnicode(table.Cells[R, c].GetRVData);
    end;
  end;
end;
procedure ConvertRVToUnicode(rv: TCustomRichView);
var
  i: Integer;
begin
  ConvertRVDataToUnicode(rv.RVData);
  for i := 0 to rv.Style.TextStyles.Count - 1 do
    rv.Style.TextStyles[i].Unicode := True;
end;
procedure ConvertSRVToUnicode(srv: TSRichViewEdit);
var
  HF: TSRVHeaderFooterType;
begin
  for HF := Low(TSRVHeaderFooterType) to High(TSRVHeaderFooterType) do
    ConvertRVDataToUnicode(srv.SubDocuments[HF]);
  ConvertRVToUnicode(srv.RichViewEdit);
  ConvertRVToUnicode(srv.RVHeader);
  ConvertRVToUnicode(srv.RVFooter);
  srv.RTFReadProperties.UnicodeMode := rvruOnlyUnicode;
end;If TSRichViewEdit is already displayed, call SRichViewEdit.Format after this procedure.
TSRVHeaderFooterType
TSRVHeaderFooterType need to refer to the unit
			
			
									
						
										
						TSRVHeaderFooterType
Thank you, can you tell me the TSRVHeaderFooterType need the unit, I won't compile
			
			
									
						
										
						- 
				Sergey Tkachenko
- Site Admin
- Posts: 17952
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If you use the older version, without SubDocuments property, the last procedure must be
			
			
									
						
										
						Code: Select all
procedure ConvertSRVToUnicode(srv: TSRichViewEdit); 
begin 
  ConvertRVToUnicode(srv.RichViewEdit); 
  ConvertRVToUnicode(srv.RVHeader); 
  ConvertRVToUnicode(srv.RVFooter); 
  srv.RTFReadProperties.UnicodeMode := rvruOnlyUnicode; 
end;