Ellipsis character does not display properly in TMemo component - delphi

A client is reporting an issue whereby she is copying from an e-mail into a screen in a program we have created with Delphi 5. The component on this screen to which she is copying is a TMemo component.
When a line of text contains an ellipsis (...) character or closing quotation marks character ("), the text is replaced with a vertical bar. If the text has two periods in a row, the periods appear correctly. When using the single quotation mark ('), the text appears correctly.
In testing this, I was able to replicate this issue from within an Outlook client and Word document. The error does not occur when copying text from within Notepad. The error also does not occur if I create the text from within the TMemo component, copy it into Outlook or Word, then copy it back into the component.

You are using Delphi 5 which is an ANSI version of Delphi. The characters that you are trying to copy do not exist in the ANSI character set that your client is using. There is no solution to this problem so long as you persist with ANSI controls. Your options:
Switch to a modern version of Delphi that supports Unicode, or
Use TNT Unicode controls with your legacy Delphi.

Related

FMX TEdit is unable to accept the ASCII single quote on iOS

I'm using Delphi 10.4 in an FMX application and, although there is no problem on Windows and Android targets, it is not possible, for the user, to enter a single quote character ' into any TEdit field on the iOS platform...
Note that if the field is initialised by program, ' is properly displayed.
Is there a reason for this or is this a bug ?

Delphi 2007 IDE hints displayed as HTML text

Since some days, my Delphi 2007 IDE has stopped formatting hint's text.
When the cursor moves over a class or a function, it displays hints as plain HTML text.
Syntax highlight is active and as far as I remember, I didn't change any option in the last months.
The only thing I can suppose is that, maybe, Windows 10 updates could have caused this problem but I'm not sure about that.

TRichEdit and Unicode - different behavior on XP and Win7

In non-unicode Delphi (I've tried with D7 and D2006):
Put a TRichEdit on the form and run the application
Switch to some "exotic" keyboard layout (Russian, Greek, whatever)
Type something
On XP, everything is good and I can see normal Russian letters. However, on Win7 characters are wrong (accented letters from other languages). If I copy Russian text from MS Word and paste it to RichEdit, it looks OK.
I suspect it is something related to RichEdit control version, but it there any way to overcome it? If possible, I would like to avoid switching to TTntRichEdit (which appears to work correctly), as I would need to change lots of existing code.
Try to use converions like AnsiToUtf8 or AnsiToUnicode, when user presses a key.

after saving delphi form, it loses accented characters

I got some forms in Delphi 7 which I open in my IDE. Certain accented characters are not displayed correctly in the form and when I change a form containing such a character , the accent is lost.
E.g. something encoded as #337 a in dfm becomes u in the saved dfm
Can you tell what may be wrong?
update:
Problem for fixed after I changed in Control Panel, Region and Language, Tab Formats.
I changed the format from English to the language that has accented character.
Delphi 7 does not support Unicode, only ASCII. That's why the "extra" characters are not displayed.
The controls are capable of showing unicode (because Windows does). But the dfm files are still ASCII, and you have no guarantees about characters above 127. (And the VCL does not support them either).
You can switch to 2010 or 2011 (XE) for Unicode support.
In a non-unicode delphi version (delphi 7 for instance), if your current codepage supports a character, then Delphi will store your accent character into the DFM. If you reload on a system that is set to a different codepage, you won't see that character.
In a unicode Delphi (2009 or later) you will be able to store any codepoint you want into the DFMs.
AFAIR, all dfm content is encoded as UTF-8, in the dfm files produced by Delphi 7.
So you could be able to use whatever character you need.
But you need to set the proper Font CharSet property value for the component.

Programmatically change the default code page in Windows XP? (from Delphi)

Could anyone advise how to programmatically change the default Windows XP code page (I'm doing this from Delphi)? (This would be the equivalent of going into Control Panel -> Regional Settings -> Language for non-Unicode applications).
In this case, I want to switch to Chinese (PRC) and so am writing to the following registry strings:
HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage\
ACP=936
MACCP=10008
OEMCP=936
(Which is exactly what changing the non-Unicode codepage drop down in Control Panel does). There must be another setting which I need to change - and I'd prefer to use a Win API call (if available) rather than writing to the registry myself.
I've also tried setting
HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language\
Default=0804 (Chinese PRC) to no avail.
I don't want to change the 'locale' per se as this will also change time / date settings, separators, etc. etc.
This is because I'm using an ANSI application that needs to render Chinese characters, and I'm writing a tool to automatically switch the system show the characters (while leaving other aspects of the UI intact).
Thanks!
Duncan
The only time this would be appropriate is if you're writing a kiosk type application where nothing else will run on the system. That change will affect every other application on the system.
If you just need to render the characters and can get them into a WideString you can render them in older versions of Delphi by calling the W versions of the Windows APIs directly, rather than going through the TCanvas methods. That is, call DrawTextW or ExtTextOutW instead of TCanvas.TextOut and it will draw the Unicode characters without converting them to the system's ANSI codepage.
A more complete option is the TMS Unicode Component Pack. It supports making Unicode-enabled applications in Delphi 6-2007, and handles calling all of the W functions for you. It works well, and you can just use TCanvas or the Caption/Text properties like normal.; the only difference is the properties are all WideStrings instead. That was originally the TNT Unicode Controls pack, and there's an older, unsupported version of that available here.
Finally, you can use Microsoft's AppLocale utility to change the ANSI codepage for just your application. There are details on calling it from a batch script here, a patch to run it without the nag screen here, and a command line clone named SBAppLocale. It works, but it's a hack, and the other options are better long-term.

Resources