Page 1 of 1

Set RVStyle.DefCodePage runtime

Posted: Tue Jul 26, 2011 12:00 am
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;

Posted: Tue Jul 26, 2011 5:39 am
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.

Posted: Tue Jul 26, 2011 6:05 am
by Marsianin
So how can I import a TXT file in desired codepage? Or change it after import...

Posted: Wed Jul 27, 2011 3:12 pm
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.

Posted: Thu Jul 28, 2011 8:36 am
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?

Posted: Thu Jul 28, 2011 10:03 am
by Sergey Tkachenko
You need just assign CurTextStyleNo, or call ApplyTextStyle.
Do you use RichViewActions?

Posted: Thu Jul 28, 2011 7:36 pm
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?

Posted: Sun Aug 07, 2011 8:54 pm
by Marsianin
:?:

Posted: Wed Aug 10, 2011 9:09 am
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.

Posted: Fri Aug 12, 2011 9:31 pm
by Marsianin
Can you tell me when do you plan to implement it?

Posted: Sat Aug 13, 2011 12:51 pm
by Sergey Tkachenko
Soon, in one of next updates.

Posted: Thu Sep 15, 2011 6:42 am
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.