This is kind of how the coding world feels about Delphi. We end up asking our coworker-hey, whatever happened to so and so, and you both try to conjure up the details of some trend that disappeared right from under your noses. SendMessage(RichEdit.There are times we do some mundane task, and we are suddenly overcome with a reminiscent sense of loss and a memory we cannot quite put a name to.
DELPHI LANGUAGE CODE
If you'd rather pull it out in a specific code page directly, then do it like this: function GetRichEditText(RichEdit: TRichEdit AnsiCodePage: UINT): AnsiString SendMessage(RichEdit.Handle, EM_GETTEXTEX, can then convert that UTF-16 string to whatever code page you like. GetTextEx.cb := (Length(Result)+1)*SizeOf(WideChar) Raise Exception.Create('EM_GETTEXTLENGTHEX failed') So, something like this would pull the text out into a UTF-16 encoded WideString: function GetRichEditText(RichEdit: TRichEdit): WideString You pass a GETTEXTEX struct which specifies the code page.
Send the underlying rich edit window the EM_GETTEXTEX message.
P.S.: Switching to Delphi 2009 or later is not an acceptable solution. How can I do that? I would prefer a solution that doesn't involve third party components, but, of course, if not possible - anything would do. I want to be able to convert the text of a RichEdit to a String (ANSI) properly, based on a character set of my choosing instead of the system's default Language for non-Unicode programs. Text value to a WideString or a UnicodeString also doesn't work properly (the text is once again in ? instead of the proper characters), it's not only when you assign it to a String (AnsiString). Lines) value of the TRichEdit, it converts its internal Unicode text to ANSI, based on the Windws' default Language for non-Unicode programs.įurther more, assigning the. I would also guess that when you get the. So I would guess that TRichEdit works with Unicode internally, as changing its Font.Charset value never changes anything - the RichEdit accepts any installed Input language properly, and if you have installed two different non-latin languages which use different character sets (Greek / GREEK_CHARSET/ and Russian / RUSSIAN_CHARSET/ for example) it would accept them both without changing its Font.Charset. Set your default Language for non-Unicode programs back to what it was before and the problem is there again. Now, if you set your default Language for non-Unicode programs to Greek (Windows restart required), this problem would disappear - greek characters would appear properly. Run the application, switch to your new (Greek) input language, type a few letters in the RichEdit and press the button - the button's caption now has ? symbols instead of Greek characters.
DELPHI LANGUAGE INSTALL