Link to home
Start Free TrialLog in
Avatar of Wim ten Brink
Wim ten BrinkFlag for Netherlands

asked on

Showing Unicode...

My manager recently asked me if Delphi supports unicode. Well, my first answer was 'Yes, of course it does! Just look at the amount of functions it has to handle widestrings etc.'
Silly me... Fortunately I did some testing before giving a final answer.

I forgot one thing however... The edit controls, the form captions, the menuboxes, the grids, the listviews and other visual components don't DISPLAY unicode correctly. And basically all our new application is retrieve data from an Oracle database through the BDE and display it onscreen.
Since it's an existing application, I have about 50 forms that have all kinds of visual components. Most of these components are data-aware components thus I can't just replace the current components with some 3rd party component set that does show Unicode... Besides, my manager made it clear that no 3rd party components can be used for this project. (Don't ask me why. Here, managers are like kings and they are allowed to create a lot of restrictions...)

Well, if I can't find a way for this application to display unicode correctly then things are quite simple. We also have a web development team and they will create the same application with ColdFusion as a web application. Actually, that would save me quite a lot of work.

However, I wonder if it's possible to add a better visual support to Delphi for displaying the texts as Unicode. Some simple API message that needs to be send to the controls or something similar to this...
Avatar of Wim ten Brink
Wim ten Brink
Flag of Netherlands image

ASKER

I have looked in the Delphi RTL/VCL source and noticed that Delphi calls the ASCII-versions of the Windows API to create the controls, forms and other things instead of the WideString versions. I think that because of this it is impossible to display unicode characters (like Chineze, Korean or Arabic) in any Delphi application. But I hope I'm wrong...

And, as said before, 3rd party controls are no option.
ASKER CERTIFIED SOLUTION
Avatar of robert_marquardt
robert_marquardt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Robert,

The first site you mentioned are exactly the 3rd party components that we don't want to use because it means we have to change all the controls on all forms. Furthermore, only 6 controls are data-aware and that's just not enough for us. It is a good set of components but rewriting the whole thing as a web application will take about just the same amount of time.

Mike Lischke (second site) also has a nice set of Unicode functions on his website but they're not really useful for me. I get the data as unicode directly from the database. I don't need to manipulate it in any way. It's just retrieving data from the database, present it to the user, allow the user to add, change or delete things and then send it back to the database.
No rocket-science required here...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I know, Bogdan... I do get the data back correctly from the database but the controls are unable to display it correctly.
Perhaps Delphi 8 will support Unicode a bit better. I also know that Visual Studio.NET 2003 supports unicode in editcontrols. And I can rewrite the application in ColdFusion as a web application...
So the only solution I have for now is to rewrite over 600 KB os source in about 100 different files. Quite expensive, considering the amount of time this will take. That's why I was hoping for a simpler solution.
Avatar of bpana
bpana

Visual Studio.NET provide full Unicode support. It would be nice if the next version of Delphi will do the same.

Bogdan
Or faff about with unicode <-> MCBS conversion, since I think that the VCL components support multi-byte chars.

When I looked into all this, I rejected that as even more effort, and went to a set of unicode controls. (Which I wrote myself - duh!)

I see no other way than the TNT controls. They already do most of what you want. The give you Unicode enabled versions of standard VCL controls.
Identify which ones are missing and learn how to do the TNT job on them. Asking the author should help especially if you donate your work to him.

600 KB is not much if the job is to mainly replace things like TLabel with TTntLabel in .dfm and .pas.
You will have to refactor your program anyway bcause i bet it is not yet fully Unicode enabled when moving strings around.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I know. I used the GExperts Replace Components tool before. Unfortunately not all my data-aware components are supported by Tnt. I have quite a few memo fields and DBLookupComboboxes in my project. Almost every form I have uses one of these unsupported controls...
Btw... My application doesn't move much strings around. Basically it displays the contents of a lot of tables and allows users to edit them almost directly. I don't have to do anything with the data, except displaying them...
Which is why a web solution isn't a big problem.

The application is an MDI application with several master-detail-subdetail-subsubdetail-etc. forms inside it. It displays a table in a grid, user double-click on it and a new form pops up with one record that can be edited and a list of detail records below it. If one of these detail records is double-clicked, another edit-form opens with possibly another list of details.

So, I know you're wondering... If this application is just a data editor, what application is using this data? Well, there are some other applications, some are webapplications, others are console C++ applications and they do most of the work. My Delphi tool is just for the configuration, which is a bit large to do in a website. (Especially since we originally wanted it to be an MDI tool.)
Well, I will probably end up rewriting this tool as a web application. No problem. Still, it took two people to convince me it could not be done without 3rd party components. Thanks, Robert, for the useful links. And Andrew, thank you for reminding me about that function in GExperts. I used it, combined with the TNT components how easy it would be to change my project into an Unicode project and after even Delphi crashed a few times he agreed that we should not even bother rewriting it in Delphi... >:-)

So, now it will become a ColdFusion project, and someone else will have to write it so I have some idle time now...