Unicode in DFM Files

I'm just mentioned how the Delphi IDE can treat Unicode-enabled source code files, but we have not seen what happens to DFM files as you add an extended character to one of the properties. A simple experiment would be

52 These two programs were part of my Mastering Delphi 2005 and I've not copied the code to the source code base of the current book, as they are rather simple. They can be downloaded from the source code of that book, though, at http: //www.mar-cocantu.com/md2005.

to open a brand new program, place a button on it, and paste in the button caption a Unicode character, like the Japanese characters of the "String Literals" section.

Viewing the Form as Text or looking at the actual DFM file you'll see the following:

object Buttonl: TButton Left = 176 Top = 104 Width = 75 Height = 25

Caption = #12354#12356 TabOrder = 0 end

Now add another form to the program (as I did in the DfmTest program, or modify the same), and this time change the Name of the button adding Unicode characters, like:

ModalResult Name

ParentBiDiMode mrNone

ButtonÈOll true

What is the effect on the DFM in this case? It will be saved in a UTF-8 format (along with the PAS file). Open it as text and you'll see an odd difference between the component Name and its Caption, which are matching but use different representations:

object Buttonafe^ : TButton Left = 224 Top = 112 Width = 75 Height = 25

Caption = 'Button'#12354#12356 TabOrder = 0 end

In this case the DFM file is not backward compatible with Delphi 2007.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment