- Why use Unicode?
- What is the situation with Unicode in Delphi, C++Builder, Kylix?
- What does LMD ElPack offer?
- Unicode controls
- Unicode hints (tooltips)
- Unicode form captions
- Unicode menus
- Unicode string operations
- Unicode file operations
- Unicode DB access
Why use Unicode?
Unicode (to be correct, UTF-8 or UTF-16 encoding of Unicode character set) is a format of choice in all modern operating systems including Windows NT/2000/XP, Linux, Windows CE/PocketPC, MacOS. It offers the following advantages:
- possibility to use words and symbols from different languages and symbol sets (like mathematical or chemical symbols) in the same text without need for complex code. IF you wonder why you might need this, just think -- how would be german-russian dictionary be made without Unicode;
- ease of handling Unicode text and faster text operations (in UTF-16, where each symbol is coded with the same number of bytes, unlike MBCS which requires use of symbols of different length);
- faster speed of operations in Windows. Windows NT/2000/XP use Unicode inside. When you operate with ANSI character sets, operating system has to waste time on converting your text to Unicode and then back to ANSI;
- easier transfer of data between different platforms. Several computers might have different active code page. This causes problems when transferring text data from one computer to another, especially if they run different operating systems (Windows, Mac, Unix);
- more flexible localization of application user interface. You don't need to think, what problems your application will have when it's time to localize user interface to, for example, Japanese.
What is the situation with Unicode in Borland products?
Support for Unicode in Delphi, Kylix and C++Builder is very limited. Until LMD ElPack 3.0 there were no solutions for Borland tools that could work with unicode on Windows 9x/ME and Windows NT/2000/XP. VCL provides only basic support for unicode strings. It's mainly conversion to ANSI and vice versa, copying and assignment of the unicode strings and memory management. There are no string lists, string functions, Unicode file operations etc.. Use of CLX allowed programmers to show Unicode text but this feature has it's own drawbacks like necessity to use QT DLL which is quite large and has a non-standard look and feel.
There exist some third-party products that extend Unicode support by either providing a set of unicode routines or letting your application show unicode text in Windows NT/2000/XP. But what about complete support including hints, menus, window captions etc.?
What does LMD ElPack offer?
LMD ElPack provides complete Unicode support for your Delphi, C++Builder and Kylix application. What does this mean?
- Unicode controls. Most of LMD ElPack controls have Unicode Text and/or Caption properties or other properties that hold the text.
- Unicode hints in LMD ElPack and other controls. LMD ElPack allows you to set Unicode hints for any controls in the application and such hints will be displayed as Unicode;
- Unicode form captions is only possible with support of LMD ElPack's components;
- Unicode menus are available with standard applications when you use LMD ElPack menu components;
- Unicode string operations with help of LMD ElPack helper methods;
- Unicode file operations using LMD ElPack helper classes.
- Unicode DB access with LMD ElPack DB controls.
Use of Unicode in LMD ElPack is optional, Unicode support can be disabled via conditional defines. If your application works mostly with ANSI data, it makes sense to avoid ANSI-Unicode conversion by turning off Unicode.
Despite advanced Unicode support for your application in LMD ElPack, the results of straight-forward use of controls can be discouraging. Please see Tips for Unicode use topic for more information about how to achieve perfect results when using Unicode.
Most LMD ElPack controls that display text, work with Unicode. Here's complete list of controls that support unicode. Please note that controls which are merely extensions of VCL controls, do not support Unicode. If some other component doesn't use Unicode, this can be easily corrected.
LMD ElPack makes it possible to assign and display hints for any control, not just LMD ElPack controls. This is possible using ElHTMLHint component, which adds optional HTML formatting and Unicode support for hints. To be able to display Unicode hints, you need to do the following:
- place an instance of TElHTMLHint to one of your forms (it's better if you place it to the main form) and set it's Active property to true;
- Assign Unicode hints to controls. For LMD ElPack controls you just set Hint property. For other controls you need to convert your hint to a special string using CreateUnicodeHintString function in ElStrUtils.pas unit and then assign this string to the Hint property of the control.
If you display long part of the hint in the status bar, you will need to use TElStatusBar component. Also, as you get Application.Hint as a string, you need to call a function ConvertHintTextW from ElStatBar.pas to convert this string hint to proper Unicode text.
Displaying of Unicode form captions is possible using LMD ElPack's TElFormCaption control. You create one or more CaptionText elements and assign Unicode hints to them. You need to set Active property of TElFormCaption to true so that it can display the text.
Unicode menus are implemented with TElMainMenu and TElPopupMenu. Besides Unicode support these components also offer support for Office XP and Windows XP styles. These components have some limitations caused by closed implementation of menus in VCL.
Unicode string operations |
ElStrUtils.pas and ElUnicodeStrings.pas modules contain set of functions and classes that simplify management and operations with Unicode strings. This includes copy/cut/merge, search and replace, comparision and uppercase/lowercase operations. Also, TElWideStringList and TElWideStringArray classes are available for easy management of Unicode string lists. Unicode functions are available separately from Unicode classes and functions page.
Unicode file operations |
File operations with Unicode text files are possible using TElWideStringList and TElWideStringArray classes. These classes are available separately from Unicode classes and functions page.
The question is very complicated. First of all, databases keep Unicode text in two formats -- UTF-16 (known as Unicode) and UTF-8 (8-bit encoding of Unicode). So you should know is how the DB works with Unicode. Second thing to take into account is what data access components you use. BDE doesn't know about fields with ftWideString type so using BDE with UTF-16 fields is not possible. ADO in general reports ftWideString fields, however in some cases the fields are reported as ftString anyway. Interbase seems to work with UTF-8 encoding.
It is possible to keep Unicode in AnsiString fields by encoding them to UTF-8, but in this case you loose some functionality (like lookup and indexing).
LMD ElPack DB controls have two operation modes that define how to treat text fields, to which the controls are linked. In first mode DB control attempts to get the field type from Delphi, i.e. ask for FieldType. As mentioned, this is the only way to work with UTF-16 fields correctly (i.e. not using AsString property of that field). Another mode is "force UTF-8", in which the control always works with the text field as if the field were holding UTF-8. This is useful for Interbase and for keeping Unicode in AnsiStrings in other databases.
[Top]
 Back to LMD ElPack Product Page