0

One of our legacy applications is in Delphi6 and we are having trouble in displaying the currency symbol of "Baht" in this application's labels and textedits.

We are using the Unicode of Baht to set the text of the labels/textedits (i.e. 0E3F) but it is always rendered as a '?'.

We tried changing the Font properties of the said labels/textedits to ANSI_CHARSET, DEFAULT_CHARSET (and even THAI_CHARSET) but no luck. And the font type selected is "Microsoft Sans Serif" which has the currency symbol of Baht (not 'MS Sans Serif' which does not have the Baht currency symbol).

Has anyone encountered this in Delphi6 and if so are there any solutions?

Thanks in advance..!!

Bathiya Priyadarshana
  • 1,325
  • 6
  • 22
  • 35

3 Answers3

2

We are using the Unicode of Baht to set the text of the labels/textedits (i.e. 0E3F) but it is always rendered as a '?'.

The ? character indicates that when the Unicode character was converted to ANSI, no character was found in the ANSI code page in use. Your options:

  1. Use an ANSI code page that includes this character, that is Windows-874.
  2. Stop using ANSI and start using Unicode.

The latter option is better, but of course a little tricky in Delphi 6 which, out of the box, is an ANSI based tool. To make Unicode GUIs with Delphi 6 you need to use the TNT Unicode components.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thanks for the response. I tried your options 1 and found that we can specify the code page as "AnsiString(874)" in Delphi 2009 and later. Any idea on how to specify the code page in Delphi6? – Bathiya Priyadarshana Jun 23 '14 at 10:14
  • What is the language setting on the machine you run this on? Option 2 is what you need. Ploughing on with ANSI in 2014 is really not a good idea. Well, really, option 3, upgrade to modern Unicode Delphi is actually what you need. – David Heffernan Jun 23 '14 at 10:24
  • Language setting in the machine is "English (Unites States)". Option 2, I am keeping as backup if nothing works (since the client doesn't like any other third party libs inside the solution which has grown over the last 10 years and already contains plenty of libs.. ;)). And yes I agree totally on upgrading to a newer version of Delphi, but that also is not an option.. :| – Bathiya Priyadarshana Jun 23 '14 at 10:32
  • The client wants you to use an ancient pre-Unicode Delphi, and not add Unicode libraries, and support international text. The client is unreasonable. I need to dig a bit to work out how to modify code page. – David Heffernan Jun 23 '14 at 10:38
  • OK, I think that you are meant to change the machine wide language settings to Thai. That might not be attractive to you. If all you need to do is paint some text with Unicode content, then you could write your own control that called `DrawTextW`. But I personally don't want to spend more of my time helping you achieve option 1 because it is a terrible idea. If somebody else wants to help you do that, fine. – David Heffernan Jun 23 '14 at 10:55
  • Another option for David's option 2 would be to put a web-front over it and use a browser to access it. At work I've used http://xxm.sf.net/ on several Delphi 6 projects. (Disclaimer: I also created xxm) – Stijn Sanders Jun 23 '14 at 18:04
2

Windows' application charmap.exe, with advanced view enabled, has a character-set selection, and when you select the character, the status-line at the bottom displays the 256-bits hex code for the character next to the unicode code point.

(Either search for "Character Map" in the start menu, or press Windows-key + R and type "charmap")

If I try it here with "Windows: Thai", I get code 0xDF for the Baht-symbol. So if you write #$DF or #223 in the string, or press Alt while typing 0 2 2 3, it should work.

Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67
1

Native pre-Unicode Delphi controls allow to enter specific local (ex Thai) characters only on a system having this specific system locale.

The workaround used for pre-Unicode Delphi versions is to replace native VCL controls by the TNT Unicode controls.

I am unaware of the TNT Unicode controls status today. You can try to search on google.

kludg
  • 27,213
  • 5
  • 67
  • 118
  • I was leaning towards the conclusion in the first paragraph. Is that right? No way to fake per app code page? – David Heffernan Jun 23 '14 at 12:55
  • I don't remember what was possible to do and what was not; the standard complete and correct solution was to use TNT Unicode Controls instead of equivalent ANSI VCL controls. – kludg Jun 23 '14 at 13:16
  • That's the solution I offered. FWIW, TNT Unicode controls are still available and still work as well as they ever did. – David Heffernan Jun 23 '14 at 13:57