Re: Using Japanese text with Delphi
- From: "Roger Lascelles" <rogerlasAToptusnet.com.au>
- Date: Thu, 1 Mar 2007 16:32:23 +1100
"Andrew V. Fionik" <ender@xxxxxxxxxxxxxx> wrote in message
news:45e64d2f@xxxxxxxxxxxxxxxxxxxxxxxxx
Hello, all.
Recently my employer asked me to add support of Japanese text in
application. The first thing i'm tried is to create simple form with TEdit
on it and enter something in Japanese. I'm was able to enter Japanese text
however when i'm switched to another language - English all characters was
immediately corrupted. Also, as i understand TEdit can return only
non-unicode strings, but for Japanese we need unicode. What i need is to
correctly input, show, read and write Japanese characters. Reading/writing
from/into XML.
You have to go to Unicode, because then your characters will appear
correctly on any PC in the world. Its the standard, it works, forget code
pages.
The Japanese have the "@MS Mincho" font loaded - a Unicode font. Its on
your WinXP install disk somewhere. Or you can get the whole experience
including character entry by enabling XP for Asian Languages - its just a
Control Panel thing somewhere.
The Tnt Unicode controls are just about the only Delphi controls which can
display your Unicode font - and they are solid.
The Tnt controls have widestring properties instead of ordinary strings -
these are 2 bytes per character and represent the characters in the Unicode
Basic Plane. Windows will accept widestrings into the API functions which
end with 'W' - even though Windows 2000 and later are actually running a
somewhat different Unicode called UTF-16. I believe that 99.999% of the
time it won't matter, especially for Japanese.
Now comes the fun part. Your app now has to use Widestrings internally so
you have a lot of work to do. But how do you store those strings in text
files and databases? For text files, I recommend converting to UTF-8
Unicode format which looks OK in an ascii editor except when you encounter a
"foreign" character. You'll have to think through your database issues.
I had no trouble extending a smallish app to permit use with Japanese
characters - actually any Unicode Basic Plane characters.
Some links
http://fundementals.sourceforge.net/unicode.html
http://www.lischke-online.de/UnicodeLibrary.php
http://mh-nexus.de/unisynedit.htm
http://mh-nexus.de/unicodenotes.htm (Delphi Unicode notes- but confusing)
http://www.tntware.com/delphicontrols/unicode/
We are all waiting for CodeGear to give us a nice Delphi which runs Unicode
throughout, but for now this is how to do it.
Roger Lascelles
.
- Follow-Ups:
- Re: Using Japanese text with Delphi
- From: Maël Hörz
- Re: Using Japanese text with Delphi
- From: Andrew V. Fionik
- Re: Using Japanese text with Delphi
- From: Bernhard Geyer
- Re: Using Japanese text with Delphi
- References:
- Using Japanese text with Delphi
- From: Andrew V. Fionik
- Using Japanese text with Delphi
- Prev by Date: Re: The Delphi Brand
- Next by Date: Win32 Delphi dependence on .NET - SDK or runtime? (was: The Delphi Brand)
- Previous by thread: Re: Using Japanese text with Delphi
- Next by thread: Re: Using Japanese text with Delphi
- Index(es):
Relevant Pages
|