Subject: Re: Q: GB, unicode and java

From: Jacob Morrison <[email-masked]>
Date: Wed, 12 Mar 1997 09:07:05 +0800

Ji Zhang,

Unicode is a superset of GB 2312 (and most other
character sets). Unicode does not use escape
codes like ISO 2022 to encode other character sets.

I am only just getting started with Java, so I don't
know all the details. Things also change in JDK 1.1.

The ideal way is to convert the GB in your source file
to UTF-8 (an 8-bit encoding of Unicode) before compiling.
I understand that there is a new command line switch
in the JDK 1.1 compiler to do this automatically for you.

If you need a GB->UTF-8 converter, look at the utf7 package (Unix)
on ftp.ifcss.org.

The Chinese may not display correctly on all platforms (only
ISO 8859-1 display is supported in the initial implementations),
though this should be fixed now.

You may also be able to embed GB directly in "byte" or String variables,
though this may not work very well.

For common knowlege, see the JDK docs :-)

Regards,
Jake

On Tue, 11 Mar 1997, Ji Zhang wrote:

> Hi there,
>
> It is said that java accepts unicode for output.
> Could unicode experts tell me what is the escape
> code for access GB, what is the escape code for
> exit GB ?  Is a code mapping needed from GB to
> unicodes or simplely keep GB as it is ?
>
> Will it look like:
>    \uhhhh \uhhhh \uhhhh \uhhhh \uhhhh \uhhhh ... \uhhhh
>      ||                                            ||
>     begin   gb     gb     gb     gb     gb   ...  exit
> in java ?
>
> Regards,
>
> Ji Zhang <[email-masked]>
>
> BTW, I do not want to "read" any docs at unicode.org.
> I just want to know a bit commom knowledge.
>

---

From: Erik Peterson <[email-masked]>
Date: Tue, 11 Mar 1997 23:24:21 -0500

>in the JDK 1.1 compiler to do this automatically for you.

  The Java Development Kit version 1.1 (JDK 1.1) comes with a
program separate from the compiler called native2ascii.  It
can convert GB2312 (or Big5 or many other encodings) in the source file
into the \uNNNN sequences that the compiler understands as Unicode characters.
  It is used as follows:
native2ascii -encoding GB2312 source.file dest.file
  At least on Windows95, it is important to capitalize GB2312 (or BIG5).

  The java.io package also supports the ability to read in documents
encoded in GB and convert it into Unicode on the way in.  Haven't worked
with this much yet though.

>If you need a GB->UTF-8 converter, look at the utf7 package (Unix)

  You can also check out my on-line GB/Big5->UTF-8 converter at
http://www.erols.com/eepeter/fileg2b.html
  You can specify a file name on your local computer and it will
return that file to the browser converted to UTF-8.  Conversion
to HZ is also supported.

>though this should be fixed now.

  It is fixed in JDK1.1, but only in Canvas widgets using drawString
or drawChars.  Extended font support for TextComponent (TextArea and
TextField) has not yet been added to the Windows virtual machine.

>though this may not work very well.

  I've tried this also with some success, although the resultant
String is hard to manipulate and compare with other Strings.

>For common knowlege, see the JDK docs :-)

  Unfortunately, the JDK docs are still developing on this topic.

Erik Peterson
http://www.erols.com/eepeter/chtools.html