This is related to my previous blog about using Chinese characters with Progress, .Net and Mono: Allow Chinese characters on a Client-Server application

Now the next challenge was to get Japanese characters to work.

I first converted the Progress database to shift-jis.
I set the environment variable: SQL_CLIENT_CHARSET=SHIFT-JIS

I then experimented with several locales, e.g. ja_JP.UTF8 and ja_JP (which is an alias for ja_JP.eucjp).

I used Wikipedia to get some sample words in Japanese characters, see http://en.wikipedia.org/wiki/Japanese_writing_system.

I soon realised that with some words I would get an ODBC error:
eg. with Kanji script 金魚 (Goldfish)
and with Hiragina script, きんぎょ
If I left out the last letter, it worked.

The ODBC error was:

Saving of data failed!
Reasons:
* [[ODBC]] [unixODBC][DataDirect-Technologies][ODBC 20101
driver][20101]Internal error -4 (unknown nls services error) in SQL from
subsystem NLS SERVICES function nlsCountChars called from nc_get_strlen
on . for . Save log for Progress technical support.

A helpful person from Progress Support gave me some suggestions, and I got it to work with Progress 9.1D in the end!
I had to use another locale, ja_JP.SJIS, which did not exist by default on my CentOS 4.6 (locale -a | grep JP).

According to http://kbase.redhat.com/faq/FAQ_80_1256.shtm
you can create the locale ja_JP.SJIS with this command:
localedef -f SHIFT_JIS -i ja_JP ja_JP.SJIS

This resolved the internal ODBC error.

Another issue was that I was not aware how to properly set the font in the ini file. Finally I found a hint in the Progress manuals, to check the prolang directory for the file progress.ini which is available for each language on the client side; this has a sample font. For the Japanese, this is a font with Japanese characters. I just copied it, and it worked.

Tags: , , ,
Posted in Software Development | Comments Closed

I recently had to provide a working solution for Traditional Chinese for Hongkong.

It involved both ODBC on the Linux server to read correct data from a Progress database, and process that data in .net on Mono, but also on the client side to be able to read data through ODBC.

Here is the solution and also some warnings about what can go wrong:

For Mono, you need to have installed the RPM package mono-locale-extras, which installs the dll I18N.CJK.dll (CJK stands for Chinese Japanese Korean).

Make sure the Progress database is in codepage big-5.
proutil mydb -C convchar convert undefined -G 15
proutil mydb -C convchar convert big-5 -G 15
_progres -pf batch.pf -1 -b -rx -p upgrade.p -param $DLC/prolang/tch/big-5/_tran.df | cat
proutil mydb -C idxbuild all

Make sure that your pf files (or even the Progress startup.pf) contain these lines:
-cpinternal big-5
-cpstream big-5
-cprcodein undefined

For the Progress server, you need to set this variable before the server is started (note: if you have both sql and 4gl server, the first one needs all settings already):
export SQL_CLIENT_CHARSET=BIG-5

Mono would rather expect BIG5 (without the dash), so we need to set another variable so that the default encoding is correct.
Before you start the server in the Mono environment, make sure that you export this variable:
export LANG=zh_TW.big5

The following command shows what languages are available on your Linux:
locale -a
Unfortunately there is no big5 for Hongkong, and zh_HK.big5hkscs does not seem to work for me. zh_TW.big5 works fine.

This code converts the data from the codepage coming through ODBC from the Progress database into Unicode:

FDBEncoding := System.Text.Encoding.Default;
try
sqlClientCodePage := Convert.ToInt32(System.Environment.GetEnvironmentVariable(‘SQL_CLIENT_CHARSET’));
FDBEncoding := System.Text.Encoding.GetEncoding(sqlClientCodePage);
except on exp: Exception do
end;

function ConvertToUnicode(s: System.String): System.String;
var
bytes: array of byte;
begin
bytes := Encoding.Default.GetBytes(s);
result := FDBEncoding.GetChars(bytes);
end;

function ConvertFromUnicode(s: System.String): System.String;
var
bytes: array of byte;
begin
bytes := FDBEncoding.GetBytes(s);
result := Encoding.Default.GetChars(bytes);
end;

For the client to be able to access through ODBC, we also need to set the environment variable in Windows XP SQL_CLIENT_CHARSET=BIG-5
(Start/Settings/Control Panel/System/Advanced/Environment Variables/System or User Variables)

Tags: , , ,
Posted in Software Development | Comments Closed

Symfony I18N   November 17th, 2007

see http://www.symfony-project.com/book/1_0/13-I18n-and-L10n

I have changed the default_culture in myapp/config/i18n.yml

Based on this blog entry with german translations I have created my own version:
save it as apps/mybackend/messages.de.xml

Tags: , ,
Posted in Software Development | Comments Closed