Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Chinese with Delphi

1,210 views
Skip to first unread message

Dennis Palmer

unread,
Jul 5, 1999, 3:00:00 AM7/5/99
to
I've seen on borland.com that Delphi supports Chinese and other Asian
languages, but I couldn't find any help on how to do it. The Delphi 4
help file says that multi-byte support is opperating-system dependant.

How do I add Chinese support to a client's opperating-system or make
sure it is there durring installation of my app? How do I get the
Chinese character support?

Thanks,
Dennis

Patrik Wang

unread,
Jul 5, 1999, 3:00:00 AM7/5/99
to

What one usually do is to install Delphi in a Chinese Windows edition,
most of the default VCL components you include will then have support
for Chinese.

You can also have Chinese support on other Windows editions as well,
for example English Windows 9x, or even NT 4. You will then need to
install the appropriate fonts and NLS files, or in Microsoft terms
'language packs'. It's available from their web site.

If you want to enable IME to actually type Chinese characters on a non
Chinese windows version, you will have to install Global IME for
simplified or traditional Chinese and have your application interface
with this COM object.

Generally, there are many more things to, why not take a look at our
MultLang Suite product, it gives you help on writing Chinese software
efficiently. http://www.lingscape.com/products/

Regards

Patrik Wang

------------------------------------------------------------------
Lingscape Ltd http://www.lingscape.com/
Multi Language in Focus Professional globalization tools

Boris Nienke

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to
Hi,

i need help on this too - but a bit different:
i would like to have chinese character support in my app that is running on
a german or english windows!
I need, for example, some menu-items in english and some other in chinese...
or some labels on the form in chinese some in english... or the labels are
in english but the user should enter the data in chinese (or vice versa)...

Is this even possible? How?

Boris

Dennis Palmer <den...@inthebible.com> wrote in message
news:37811F78...@inthebible.com...


> I've seen on borland.com that Delphi supports Chinese and other Asian
> languages, but I couldn't find any help on how to do it. The Delphi 4
> help file says that multi-byte support is opperating-system dependant.
>
> How do I add Chinese support to a client's opperating-system or make
> sure it is there durring installation of my app? How do I get the
> Chinese character support?
>

> Thanks,
> Dennis

Patrik Wang

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to
On Tue, 6 Jul 1999 08:39:57 +0200, "Boris Nienke" <bni...@mcis.de>
wrote:

>Hi,
>
>i need help on this too - but a bit different:
>i would like to have chinese character support in my app that is running on
>a german or english windows!
>I need, for example, some menu-items in english and some other in chinese...
>or some labels on the form in chinese some in english... or the labels are
>in english but the user should enter the data in chinese (or vice versa)...
>
>Is this even possible? How?
>
>Boris

Yes, this is possible with some manual work.

First you will need to install the Chinese simplified or traditional
language packs from Microsoft into Windows 9x, NT (you do not need to
install language packs on Windows 2000, just enable it from the
regional settings in control panel)

Secondly, you will need to design the form components with correct
Font (such as MS Gothic) and charset to display Chinese characters
correctly. On an English or German Windows edition, this can be quite
hard for components such as TMainMenu since it does not have a Font
property, but it is still possible by setting the default menu Font,
or using a third party menu component, or doing OwnerDraw.

Third, you will also need to install the Global IME for Chinese from
Microsoft, which will enable you to type chinese characters in your
edit fields on a English or German windows edition. However, you
cannot just install the Global IME, you will have to create an
interface and use the Message Pump COM object to process Chinese
characters.

Our MultLang Suite tool, can help you do many of these tasks for you
and put form translations in a Unicode database that can be used on an
English or German Windows edition. Our Language Workshop localization
tool can be used to translate your existing forms to Chinese on
English and German windows versions with the help of Global IME.

Maybe this sounds very complicated, but in fact it is not that hard to
do. Many of the technologies I have shared on this newsgroup are built
in to our forthcoming VCL Suite for Unicode. For example, you will
simply drop a TUEdit component onto the form and have this
functionality already working, type Chinese, Japanese, Arabic, German
and English characters on the same line and edit control.

Dennis Palmer

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to
Received via private e-mail from ja...@cyberzone.net (Maynard
Philbrook):

The OS has alot to do with it.
you can select the Charactor set by setting the canvas.Font.charset :=
????
look up the TFONT.Charset -==
You can get your LCID if you look at the system Fonts.

Charset specifies the character set of the font.

TFontCharset = 0..255;
property Charset: TFontCharset nodefault;

Description

Set Charset to identify the character set of the font. Each typeface
(specified by the Name property) supports one or more character sets.
Check the information supplied by the font vendor to determine what
values
of Charset are valid.
The following table lists the predefined constants provided for standard
character sets:

Constant Value Description

ANSI_CHARSET 0 ANSI characters.
DEFAULT_CHARSET 1 Font is chosen based solely on Name and Size. If the
described font is not available on the system, Windows will substitute
another font.
SYMBOL_CHARSET 2 Standard symbol set.
MAC_CHARSET 77 Macintosh characters. Not available on NT 3.51.
SHIFTJIS_CHARSET 128 Japanese shift-jis characters.
HANGEUL_CHARSET 129 Korean characters (Wansung).
JOHAB_CHARSET 130 Korean characters (Johab). Not available on NT 3.51

GB2312_CHARSET 134 Simplified Chinese characters (mainland china).
CHINESEBIG5_CHARSET 136 Traditional Chinese characters (taiwanese).
GREEK_CHARSET 161 Greek characters. Not available on NT 3.51.
TURKISH_CHARSET 162 Turkish characters. Not available on NT 3.51
VIETNAMESE_CHARSET 163 Vietnamese characters. Not available on NT 3.51.
HEBREW_CHARSET 177 Hebrew characters. Not available on NT 3.51
ARABIC_CHARSET 178 Arabic characters. Not available on NT 3.51

BALTIC_CHARSET 186 Baltic characters. Not available on NT 3.51.
RUSSIAN_CHARSET 204 Cyrillic characters. Not available on NT 3.51.
THAI_CHARSET 222 Thai characters. Not available on NT 3.51
EASTEUROPE_CHARSET 238 Includes diacritical marks for eastern european
countries. Not available on NT 3.51.
OEM_CHARSET 255 Depends on the codepage of the operating system.

Peter Below (TeamB)

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to
> I've seen on borland.com that Delphi supports Chinese and other Asian
> languages, but I couldn't find any help on how to do it. The Delphi 4
> help file says that multi-byte support is opperating-system dependant.
> How do I add Chinese support to a client's opperating-system or make
> sure it is there durring installation of my app? How do I get the
> Chinese character support?

Dennis,

i should probably keep my trap shut since i have no personal experience
with these things at all but my understanding of these matters is this:

you can get chinese (or other far-east language) characters to display
on an non-far-east Windows version if you install a proper font on the
system but you will not get the input method editor (IME) support for
user *input* in these languages. The IME support is part of the OS and
the only way to get it is to install the far-east version of Windows,
as far as i know. Unless you want to write your own IMEs, of course <g>.

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!


Dennis Palmer

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to
Peter Below (TeamB) wrote:
> Unless you want to write your own IMEs, of course <g>.

Any posibility of finding an IME in the form of a Delphi component or a
DLL?

Thanks for the help. I downloaded the Internet Explorer extensions for
Chinese, which enabled me to view the Chinese characters online with
IE. I think that included the fonts, so from what I've read here I
should be able to now use those fonts in a Delphi app. That's what I'm
going to try next.

Dennis

Graham Stratford

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
If inputting Chinese is anything like inputting Japanese, creating an
IME would be a HUGE task! If someone types in (using Roman phonetic
spelling, rather than a Japanese keyboard, which you might also have to
check for) "chi," it's trivial to translate this to the appropriate
Japanese phonetic character. Converting it to a kanji (Japanese
equivalent of hanzi(?)) is a pig, because a single syllable could be
represented by any one of hundreds of characters. Often you have to try
and match a series of syllables to figure out what the most likely kanji
are going to be, and always present a list of possible alternatives
(also often more than 100).

You would need big indexes, and a high-native mastery of the language,
to do it properly. A couple of companies have done it for Japanese, and
their products (which also display Japanese and hook into the Windows
system so they are transparent) cost hundreds of dollars.

Not to discourage you, but dealing with far East characters (aside from
just displaying them) on English Windows is a daunting undertaking.

Graham Stratford

Patrik Wang

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
On Wed, 07 Jul 1999 10:02:54 +0900, Graham Stratford
<gra...@xoommail.com> wrote:

>Not to discourage you, but dealing with far East characters (aside from
>just displaying them) on English Windows is a daunting undertaking.
>
>Graham Stratford
>
>Dennis Palmer wrote:
>>
>> Peter Below (TeamB) wrote:
>> > Unless you want to write your own IMEs, of course <g>.
>>
>> Any posibility of finding an IME in the form of a Delphi component or a
>> DLL?

I must agree that it is necessary to understand on how Chinese works
in order to write applications for it. But it is not so difficult that
one could imagine, since most issues are built in to VCL's and to the
Win32 OS system.

However, you do not have to write an own IME, Microsofts Global IME is
free of charge, cost nothing, and it can be installed into any Win32
OS. So this enables you to write (type) chinese characters on an
English or German windows version.

MS Global IME can be used to type the roman way, convert it to Kana,
Kanji or whatever, while typing. It has its own built in dictionaries
and lookup tables just as with Japanese Win 98 IME.

Since the new release of Global IME you now only need to interface
with the COM (ActiveX) component to enable this in your application.
We are building this functionality into our MultLang Suite product so
that it comes automatically if the OS have it installed.

If we will receive some requests, we can produce a cheap component
that have this Global IME support built in. This would enable the IME
to work on standard English, German Windows, with any Delphi standard
component on the form.

Andy Jeffries

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
> i should probably keep my trap shut since i have no personal experience
> with these things at all but my understanding of these matters is this:

Nah, always good to hear from you, on all matters...

> you can get chinese (or other far-east language) characters to display
> on an non-far-east Windows version if you install a proper font on the
> system but you will not get the input method editor (IME) support for
> user *input* in these languages. The IME support is part of the OS and
> the only way to get it is to install the far-east version of Windows,

> as far as i know. Unless you want to write your own IMEs, of course <g>.

If you download the full IE5 it comes with IMEs for Chinese, Japanese and
Korean. Of course, I have no knowledge of the Chinese one in question, but
the Korean one works very well. I am able to send and receive e-mails in
Korean quite adequately (apart from my terrible Korean).

Also, a search through the Microsoft site should reveal something for
"Global-IME" which is a download for western windows to use eastern
characters.


--
Andy Jeffries

Andy Jeffries

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
> Not to discourage you, but dealing with far East characters (aside from
> just displaying them) on English Windows is a daunting undertaking.

Just to add my 2p, dealing with Korean characters on Western Windows is very
easy. Although the Korean alphabet (han'gul) is quite simple. I believe
it is a similar system to katakana, although I have next to no knowledge of
Japanese (and even less about written Japanese).


--
Andy Jeffries

Graham Stratford

unread,
Jul 8, 1999, 3:00:00 AM7/8/99
to
Yes, I think that Han'gul is really a phonetic system, with characters
composed of 1 to 3 (4?) "bits" that each have a fixed pronunciation.

Japanese, in contrast, is a nightmare. The syllable "ko" could be
written as any of 51 standard kanji. Turning it around, the character
for "life" has 12 different pronunciations! The amazing thing is that
the Japanese literacy rate is something like 97%.

Graham

dda...@inet-1.com

unread,
Jul 8, 1999, 3:00:00 AM7/8/99
to pw...@lingscape.com
Hi Patrik,

I am intrigued by the Global IME, and am downloading the versions for
Chinese and Japanese now. I assume that Microsoft has documentation
somewhere that explains how to interface with it.

I would like to know how you deal with certain "problem" delphi
components that do not appear to work correctly when changing the
fontname and charset property.

In doing some testing using English (US) Windows NT (SP5) and Delphi 4
Client/Server (patch 3), we have discovered that trying the Charset
property has no affect on several delphi componets such as TButton,
TEdit, TGroupbox, etc... I assume this is because these delphi
components encapsulate standard windows controls which do not normally
have a charset property.

However the same application running on a native Japanese Windows 98
system (with the font name set to MS Gothic, and font charset set to
128), the japanese characters display correctly. I assume you are using
your own Unicode VCL which may not have this problem, but would be
interested in knowing if there is a fix for this problem.

Incidently we are using your MultLang suite to handle to translation
tasks for us. It appears that your new Language Workshop tool is
incompatible with the ULM files generated by current release of MultLang
Suite 2. Is there an upcoming release of MultLang that will fix this
problem?

- Darren Davis
Brookline Technologies

> Regards
>
> Patrik Wang
>
> ------------------------------------------------------------------
> Lingscape Ltd http://www.lingscape.com/
> Multi Language in Focus Professional globalization tools
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Andy Jeffries

unread,
Jul 8, 1999, 3:00:00 AM7/8/99
to
> Yes, I think that Han'gul is really a phonetic system, with characters
> composed of 1 to 3 (4?) "bits" that each have a fixed pronunciation.

Correct, 1 to 4.

> Japanese, in contrast, is a nightmare. The syllable "ko" could be
> written as any of 51 standard kanji. Turning it around, the character
> for "life" has 12 different pronunciations! The amazing thing is that
> the Japanese literacy rate is something like 97%.

Rather you than me...

Why are you learning/speaking Japanese? Have you Japanese clients or are
you living there?


Andy

Graham Stratford

unread,
Jul 8, 1999, 3:00:00 AM7/8/99
to
Sigh. Yes, I live here, in The Big Cement. My wife is Japanese, and that
makes our son half-Japanese (if I remember my biology correctly :-)). I
work at a big software company, but my job has degenerated from doing
some programming and some translation and some liaison work, into. . .
sales. Blah.

I'm pining for the fjords -- er, at least the open spaces and nature --
of my native Ontario, though, and shudder at the thought of Kento going
to Japanese schools, so a trip back over the Pacific is not all that
improbable in the next year or two. Sooner if my company decides that
I'm a lousy salesman (I am), and there's no place for me there.

At least we were spared most of the Asian meltdown here, but it seems to
be more of a long, drawn-out death by a thousand cuts. Recently,
economists and politicians have been trumpeting nonsense about "turning
the corner" and "the recession is stopping," but I don't believe them
about anything else, so why should I believe them about this?

Graham

P.S. Perhaps we shouldn't continue this in ObjectPascal

Dennis Palmer

unread,
Jul 10, 1999, 3:00:00 AM7/10/99
to
Using Delphi 4, I placed a TMemo on a form and inserted a text file that
I saved from a web page that has chinese characters. This web page
displayed the chinese when viewed with Internet Explorer.

I selected the chinese font and the chinese character set, but the
characters did not display properly.

Do I need to use a different control? What else needs to be done to
make this work?

Thanks,
Dennis

Darren Davis

unread,
Jul 10, 1999, 3:00:00 AM7/10/99
to Dennis Palmer
I was able to copy Japanese characters into a Delphi 4 TMemo by doing the
following:

1) Add a TMemo to a form and change the Font.Name property to MS Gothic,
and Font.CharacterSet to Shift_JIS

2) Got to a Japanese Web Site using NetScape

3) From the VIEW menu of netscape, change the Characterset property to
Shift_Jis.

4) Select the text from the webpage, and press Ctrl C to copy to Clipboard.

5) Double-click on the Lines property of the memo in Delphi and Press
Ctrl-V to copy the text from the Clipboard.

The memo field shows Japanese.

This same method should work with Chinese or Korean if you have a Chinese
font installed. I use NT 4.0, and the fonts and character set mappings for
Asian languages are found on the NT Workstation CD-Rom under the LangPack
directory. If you are using Windows 95/98, you will need to go to the
Internet Explorer Webpage, and download the "language pack upgrade" for
Internet explorer. This will install the correct fonts and character set
mappings onto your computer.

I don't use Inernet Explorer as my browser, but would assume that it has a
way to specify the charset of the displayed text. If not, use Netscape
Communicator.

Good Luck

Dennis Palmer

unread,
Jul 12, 1999, 3:00:00 AM7/12/99
to
Darren,

I don't have MS Gothic on my system. Using Windows 95 I downloaded the
2 IE lang packs for simple and traditional chinese. Big5 encoding (I
think that's traditional) uses the MingLiU font. I followed your
instructions using this font and a web site displaying some chinese
text. I prefer using Netscape, but until now hadn't gotten it to
display the chinese. The text in the Delphi Memo did not display
properly.

Even IF I can get this to work, what issues are involved in
redistributing these fonts that come from the IE lang upgrade packs?
Does each end-user have to download this? Can I put it on our CD-ROM?
What does it do other than install the fonts?

Thanks,
Dennis

Vincent Yip

unread,
Jul 14, 1999, 3:00:00 AM7/14/99
to
Hi Dennis,

To write Chinese applications, use the Chinese versions of windows if
you know the language or
a Chinese supporting s/w if you don't. For personnal preference, I use
'Union Way' supplied by
my local ISP in HK with English windows. 'RichWin' is another famous
one. Or you may find others
in your local supplier or the internet.

If you want to use Chinese windows, choose the correct version -
Simplified or Traditional -
according to you end user. Supporting s/w's usually support both of
them, and also Korean and
Japanese.

Since Chinese system makes use of the 2nd page of the ASCII table for
encoding, European windows
using bytes with MSB set for accent alphabets will not work smoothly.

Vicent.

Boris Nienke

unread,
Jul 14, 1999, 3:00:00 AM7/14/99
to
Hi Vincent,

thank you for this information!
I've found a s/w called "Chinese Star" with which a software that i use to
learn chinese can display the chin. symbols on my german WinNT.

But what have i to do, if i would like to display these symbols in my own
delphi application? I can't get it to work...

Any help would be greately appreciated

Boris

Vincent Yip <Vin...@HongKong.com> wrote in message
news:378B76B4...@HongKong.com...

Gary Cuevas

unread,
Jul 14, 1999, 3:00:00 AM7/14/99
to
Hi, everyone,

Sorry I missed the beginning of this thread - I have a question I'm sure
someone here can help me with...

I'm trying to get a small Delphi 4 app localized to Japanese and Chinese
Simplified. Our company has successfully taken our product that was
originally developed in English and has used the wizard in Delphi to create
resource-only DLLs. We then had translators change them to French, German,
Italian, Portuguese and Spanish. When we name the files with .FR, .DE, .IT,
.PO and .ES, our Delphi app detects the resources and uses them on the
foreign machines.

I'm having trouble with this scheme for Japanese and Chinese. I'm using .JA
for Japanese and .ZH for Chinese. But when I run the app on a Japanese
Win95 machine, I get all empty strings where I expect to see text.

My question is if I need to do something special in the app to accommodate
MBCS or DBCS. My other question is whether this scheme is designed to work
with Asian languages at all - I noticed the Delphi wizard does not give
options for creating the Asian DLLs.

Can anyone offer some guidance for me?

Thanks so much.

(Please note I've posted a similar message here titled "International
Resource DLLs".)

Gary Cuevas
Socket Communications

Vincent Yip

unread,
Jul 15, 1999, 3:00:00 AM7/15/99
to
Hi Boris,

"Chinese Star" is OK.

In Delphi, all string text entities can be use to display the Chinese
characters. Cells of TStringGrids, Captions of TLabels, comments in the
source code, string-constants, etc. can be filled with them. However,
the use of Chinese characters in Names of components, variables, etc may
not work; just restrict to text fields.

Vincent.

Graham Stratford

unread,
Jul 15, 1999, 3:00:00 AM7/15/99
to
One point that springs to mind is the problem of indexing on strings. If
you want to move to the third character in a MBCS string, it could be
anywhere from the third to the fifth byte -- you would have to count
from the beginning of the string to know exactly. There are functions
that ease these problems, but you can't blithely use the normal methods.

Graham

--
Graham Stratford
Japan Computer Science (JCS) Corp.
stra...@kb.jcs.co.jp

Boris Nienke

unread,
Jul 15, 1999, 3:00:00 AM7/15/99
to
Hi Vincent,

yes, that's all clear.
But what have i to do (what strings) to let chinese star "translate" the
chars into a chin. symbol?
Sometimes i've seen things like "^C" or such...
What i can do what ever i want, i alway see just the german/english letters
(or spezial characters) ...

So, could send me a small text-example with chinese characters?
Thank you

Boris

Vincent Yip <Vin...@HongKong.com> wrote in message

news:378CB4D8...@HongKong.com...

Patrik Wang

unread,
Jul 15, 1999, 3:00:00 AM7/15/99
to
On Wed, 14 Jul 1999 10:18:02 -0700, "Gary Cuevas"
<gary@!!nospam!!.socketcom.com> wrote:

>Hi, everyone,


>
>I'm having trouble with this scheme for Japanese and Chinese. I'm using .JA
>for Japanese and .ZH for Chinese. But when I run the app on a Japanese
>Win95 machine, I get all empty strings where I expect to see text.
>
>My question is if I need to do something special in the app to accommodate
>MBCS or DBCS. My other question is whether this scheme is designed to work
>with Asian languages at all - I noticed the Delphi wizard does not give
>options for creating the Asian DLLs.
>

You should compile the resource DLL on the Asian edition of Windows in
order to get it to work correctly. If you have created RC string
tables on your own, you also need to tell the resource compiler to use
DBCS codepages (there's a switch).

However, when we built our MultLang Suite package we did it with
latest Unicode standard and it is there for possible to create Asian
editions of DLL's and EXE's on an American Windows version.

Vincent Yip

unread,
Jul 16, 1999, 3:00:00 AM7/16/99
to
Boris,

English : "Boris, how are you ? I hope this can help you."
GB : "布力士,你好吗?希望这能帮到你。"
Big5 : "ガ盾辨硂腊"

With "Chinese Star" running, select GB and Big5 alternatively and you
will see the similarities of the lines. The correctly displayed line
should have only 3 punctuation marks inside the quotes.

Since they are text, just copy to any string in your Delphi program and
see.

Good luck.

Vincent.

Boris Nienke wrote:
>
> Hi Vincent,
>

David Mason

unread,
Jul 23, 1999, 3:00:00 AM7/23/99
to

Did you ever succeed in displaying Chinese characters in Delphi?

I've been trying to find out how to do it for a few weeks, and have just
found this thread (I should have looked here first, really...). It is
somewhat inconclusive.

Vincent Yip

unread,
Jul 25, 1999, 3:00:00 AM7/25/99
to
Hi David,

I had posted some ideas with this thread, can you find them ? Or do you
have other difficulties in handling Chinese with Delphi ?

Vincent.

David Mason

unread,
Jul 25, 1999, 3:00:00 AM7/25/99
to
.> Hi David,

Hi. Thanks for your reply.

> I had posted some ideas with this thread, can you find them ? Or do you
> have other difficulties in handling Chinese with Delphi ?

I have found 3 messages from you to various people. The most relevant
message says that:

"In Delphi, all string text entities can be use to display the Chinese
characters. Cells of TStringGrids, Captions of TLabels, comments in the
source code, string-constants, etc. can be filled with them. However,
the use of Chinese characters in Names of components, variables, etc
may not work; just restrict to text fields."

Displaying Chinese characters in captions of TLabel objects is one problem
I want to solve. I have the MS-Song font installed. But if I set a TLabel
object
(or any other text displaying component) to have the MS-Song font, with the
GB char set(the only one it lets you have), any Chinese characters that I
paste into the caption (from a web page) get displayed as question marks.

I might try a different IME and see if I can input them directly.

Vincent Yip

unread,
Jul 26, 1999, 3:00:00 AM7/26/99
to
David,

Maybe the your web page is not in GB or is in special web formats.

I have 3 lines for you:
English : "David, how are you ? I hope this can help you."
GB : "大卫,你好吗?希望这能帮到你。"
Big5 : "矫盾辨硂腊"

Also try this link: it is in GB
http://www.centanet.com/schome/home.htm

Save this thread in .txt. Save the web pages you want to try in .txt.
Open the txt files in Notepad and select the MS-Song font you have. If
you can display them in Notepad, you can copy any text from there to
your Delphi texts.

Good luck.

Vincent.

Boris Nienke

unread,
Aug 3, 1999, 3:00:00 AM8/3/99
to
Hi David,

currently i gave up (because of no time) but i'll try the suggestions from
Vincent Yip. He has posted some chinese text here and if i'm able to copy it
to delphi... well then all that i need is an "input-interface" :-)

cu

Boris

David Mason <drm...@xtra.co.nz> wrote in message
news:7n945j$o9...@forums.borland.com...

David Mason

unread,
Aug 5, 1999, 3:00:00 AM8/5/99
to

> currently i gave up (because of no time) but i'll try the suggestions from
> Vincent Yip. He has posted some chinese text here and if i'm able to copy
it
> to delphi... well then all that i need is an "input-interface" :-)

I think you'll find it doesn't work like that. The reason is that the VCL
components all use the SBCS string writing functions. I have now succeeded
in displaying Chinese characters from the MS Song and MS Hei TT fonts.

To do this, you must convert the GB2312 string to Unicode, then pass the
Unicode wide string to the OutTextW function.

The following code will display the characters, if you pass it a string such
as the GB one that Vincent Yip provided (thanks Vincent!).

{----XieHanZi---------------------------------------------------------------
----------------------}
// The Font property of the canvas parameter MUST be set to a UNICODE
// Chinese font, such as MS-Hei or MS-Song
procedure XieHanZi(Canvas:TCanvas; x,y:integer; GB:string);
var W:PWideChar;
GBlength, UNILength, WSize:integer;
begin
GBLength:=Length(GB);

// Horrible things happened when I used a PWideChar cast on
// a WideString, and this is the only reliable way I found:

// Each single char in GB could become two bytes
// Also might need two bytes for the zero terminator.
WSize:=GBLength*2 + 2;
GetMem(W, WSize);

// It seems that MultiByteToWideChar doesn't put in a 0 terminator
ZeroMemory(W,WSize);

// Convert from code page 936 (PRC, Singapore) to UNICODE
MultiByteToWideChar(936,0,PChar(GB),GBLength,W,WSize);

// Get length of UNICODE string
UNILength:=LStrLenW(W);

// Write the text
TextOutW(Canvas.Handle, x,y,W,UNILength);

// Clean up
FreeMem(W, GBLength*2+2);
end;

{---------------------------------------------------------------------------
--------------------------}

This can easily be modified to display MingLiu in Big5, just change the
code page 936 to 950, and pass a big5 string instead of GB.

0 new messages