Set (default) charset for a document

  • Hello!

    Unfortunately the philosophie and conzept of codepage and charset handling in WPTools is not documented, so i don't find my informations. So, here are my questions:

    I want to switch (at runtime) an application's country settings, which shall be absolutely independent from the current window's settings. Setting TFont's charset, most controls successfully show the text taking the new codepage characters. But how to do this for WPTools?

    How can i set the (default) charset for a new doc?

    I tried this (example: RUSSIAN_CHARSET), but this didn't help at all - text is DEFAULT_CHARSET.
    WP->EditOptionsEx = WP->EditOptionsEx <<wpDisableAutoCharsetSelection>AttrHelper()->SetFontCharSet( RUSSIAN_CHARSET );
    WP->DefaultAttr()->SetFontCharSet( RUSSIAN_CHARSET );
    WP->CurrAttr->CharSet = RUSSIAN_CHARSET;

    Another question: When the doc is opened in another country setting environment, is the text correctly shown with the saved charset?

    BTW, having some tests, while editing one doc. WPTools crashed, when often adding, removing and changing window's country settings (you know, the blue symbol 'DE' etc. in the tray) .

    Thank you,
    E. Hess

    • Offizieller Beitrag
    Zitat

    Unfortunately the philosophie and conzept of codepage and charset handling in WPTools is not documented, so i don't find my informations.

    It is documented - you also have the PRO version which includeds the source for the method UpdateCodePage in WPRTEPaint.pas. That is executed when the language is changed. There is nothing it it which can cause a crash - as far as I can see, does anybody?

    WPTools uses internally unicode characters, the CharItem in a TParagraph are WideChars. Only the first 256 values are bound to the 1252 codepage.

    Zitat

    I tried this (example: RUSSIAN_CHARSET), but this didn't help at all - text is DEFAULT_CHARSET.
    WP->EditOptionsEx = WP->EditOptionsEx <<wpDisableAutoCharsetSelection>AttrHelper()->SetFontCharSet( RUSSIAN_CHARSET );
    WP->DefaultAttr()->SetFontCharSet( RUSSIAN_CHARSET );
    WP->CurrAttr->CharSet = RUSSIAN_CHARSET;

    It will help, but only for the text which is immediately inserted after the assignment to CurrAttr.

    You can update Memo._CodePage

    Regards,
    Julian Ziersch