I'm using Delphi 2007 and I need to pick and display a character from a unicode font in the range U+1500 to U+15FF

I tried:

label1.caption := widechar($1513);

but it can't be that simple. I have googled unicode, delphi, chr, widechar etc and researched for days and I still can't figure it out. Hoping someone can help. Thanks.

Unfortunately, Delphi really doesn't have very good support for Unicode. Widestrings really only exist for compatabilty with OLE objects...

Lately I've been learning a lot about using Unicode in my applications (both Delphi and C++) too, and it is a big, messy world.

MSDN Unicode and Character Sets

The Delphi I18N Cookbook

CodeGear Documentation Creating International Applications

Well, that should get you started. Good luck!

Thanks for the info. Actually I had come across every one of the pages you listed before. I told you I was at this for a while! I still can't figure out how to display just one chr() from a U+ font. I can't imagine it should be so hard.

Hi,

I used to participate in developing a unicode app. using Delphi 2007 at my previous job and can say that this is not a simple area, really. But the company's programmers implemented their own ansi2unicode/unicode2ansi engine and own VCL components such as labels, buttons, and so on.

if you need to just display a unicode character(s), you can implement a simple label-replacement component which will use DrawTextW() or TextOutW() API function. Both of those functions draw unicode text on Canvas with no problem.

Sincerely,
Tom Barnet
HelpSmith 2.0 is Released. Have You Yet Upgraded?

Tom, thanks for the insight. i am a bit of a newbie here so if you can help me out with some code I would be grateful!

I want to input a unicode, say U+1500 and have it print out to a character position (1 to 3) I select in a label. Thanks again.

I figured it out using drawtextw. Thanks!

Your best long term bet would be to start using the TNT component suite. It is no longer freeware but you can still get an updated version of the last freeware version here

TNT Controls

By and large TNT controls are a drop in replacement for the equivalent Delphi ones. If you have already got a number of forms with the "normal" controls here is a quick and easy way to do the conversion

  1. Install the TNT component suite
  2. With each form in your project hit Alt + F12 to see the DFM code.
  3. Now systematically replace T* with TTnT* where * is Label, Edit, Memo etc.
  4. Hit Alt + F12 again to see the form designer.
  5. Save the form. At this point Delphi will prompt you to correct the control declarations - e.g. from Label1:TLabel; to Label1:TTnTLabel.
  6. Just keep saying Yes till you are all done

Compile and enjoy! Couldn't be easier! Apart from that you might occasionally need to draw text directly using the DrawTextExW Windows GDI function call.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.