Operating System - HP-UX
1834926 Members
2201 Online
110071 Solutions
New Discussion

Converting MBCS string to USC2 for Java client.

 
Jens Fauth
Occasional Contributor

Converting MBCS string to USC2 for Java client.

Hello,

I have the following problem:

We have a program that is reading directories and filenames form the disk and send it to a Java client.
In the first version we used mbstowcs(...) to convert the string.
The first problem is, that the type wchar_t is 4 Bytes long. But Java wants 2 Byte wchar_t. So I truncate the upper
2 bytes of the wchar and generate an 2 byte wchar.
This works perfect for English characters. But the Java client cannot display Japanese or other characters.
The first question is, why did mbstowcs not convert to UCS2 or UCS4? Because the output of the Japanese characters
is not UCS2 or UCS4.

To solve the problem I tried to use iconv(...). For iconv I have an real Local to UCS2 converter and need no
truncation of the characters. iconv_open(...) has no problems. And the conversion of the English characters
are working perfect. But if I try to convert an Japanese string. I get the errno (251) Function not implemented.
I have installed all patches that I can get.
Nothing solves the problem.

I hope someone can help me.

I have a HP Visualize Workstation C3000 with HPUX 11.0 and all available patches.

Best regards and thanks
Jens Fauth
2 REPLIES 2
Kenneth Platz
Esteemed Contributor

Re: Converting MBCS string to USC2 for Java client.

Jens,

While ENOSYS is not specifically mentioned in the iconv(3C) manpage, this most likely indicates that you do not have the appropriate Japanese filesets installed on your system. The Japanese (and other Asian language) filesets are not included as part of the Core OS (like the European languages); these are part of the ASE (Asian Support Environment) which is installed with product B1515AA (for series 700) or B1520AA (for series 800). Once you install those, you should see the following products:

Asian-Core
Asian-Graphics
Asian-PRINTER
Asian-TERM
Asian-UTILITY
Asian-X11
Asian-X11FONT
Asian-XDEVICE


If you do already have these installed, then what locale are you trying to convert from and to? HP supports the following Japanese character sets:

eucJP
kana8
SJIS
utf8 (an encoding of ISO-10646 Unicode)

You should see the following files in /usr/lib/nls/iconv/tables:

eucJP=ucs2 sjis=ucs2 utf8=ucs2

These are the conversion tables for eucJP->UCS2, SJIS->UCS2, and UTF8->UCS2 encodings.

You can also try using the "iconv" command-line program to attempt to convert one file at a time, to see if that will provide the functionality you need.

I hope this helps.




I think, therefore I am... I think!
Jens Fauth
Occasional Contributor

Re: Converting MBCS string to USC2 for Java client.

Thank you for the answer.

I have checked the installation of the machine, and detected that the parts Asian-Graphics and
Asian-XDEVICE are missing. I don't know if they are necessary.

I am using ja_JP.eucJP and want to convert to UCS2.

All converter are present and iconv(1) is working. I have no idea why my program is not working.

Best regards
Jens