Set RVStyle.DefCodePage runtime

General TRichView support forum. Please post your questions here
Post Reply
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Set RVStyle.DefCodePage runtime

Post by Marsianin »

My program is multilingual so when user change program language I need to change CodePage for imported TXT files too.
RichViewEdit is Unicode but I need it for TXT import.
Setting RVStyle.DefCodePage in IDE does the job but run-time it changes nothing.
I tried to set codepage to 1251 run-time (was 0 - ANSI Default) and imported Cyrillic text file - got wrong characters.

Looks like this does not work:
RVStyle1.DefCodePage:=1251;
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It does not matter if you assign this property at run- or design-time.
However, Charset property of text styles have higher priority than this property. This property is used only if the text Charset=DEFAULT_CHARSET.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

So how can I import a TXT file in desired codepage? Or change it after import...
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you define the file code page in DefCodePage, then:
- if you load using LoadText, specify the index of text style having Charset=DEFAULT_CHARSET
- if you insert using InsertTextFromFile, apply a text style with Charset=DEFAULT_CHARSET before calling this function.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

I'm inserting via InsertTextFromFile to a not empty Unicode document so I have to select inserted data and apply style?
How can I select it?
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You need just assign CurTextStyleNo, or call ApplyTextStyle.
Do you use RichViewActions?
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Yes, I'm still using rvActions but step by step removing them from my project.
So when should I assign CurTextStyleNo and will it affect current text with this style?
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

:?:
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, it will affect the inserted text.
In future version, we plan to add a code page of text as a parameter.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Can you tell me when do you plan to implement it?
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Soon, in one of next updates.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The solution is included in the new update (available for registered users).
But only for Unicode documents.
In the text saving/loading methods, you can specify an additional optional CodePage parameter, defining a text file encoding. This code page will be used for conversion between ANSI/DBCS (file) and Unicode (document).

RichViewActions display a dialog for choosing a text file encoding when saving/loading a text file.

This feature will be available in the public (trial) version soon, at the beginning of the next week.
Post Reply