RSS

Tag Archives: DBCS

Inserting Japanese characters into a NAV database from outside NAV

In a previous post I described some steps on how to enable you NAV environment to support DBCS. Read more about it here: http://kennyvaes.wordpress.com/2009/06/08/nav-vs-dbcs/

Now, the next challange we faced was inserting Japanese characters from an external system into the NAV database.

In other countries we mangage this by running a webservice which insert the information into the SQL database. This webservice is built in C#.

The problem now on the Japanese system was that the strings passed on to the webservice are all Unicode, because .NET handles all strings as Unicode.

Just inserting these Unicode bytes in NAV without conversion will result in a string like “日本 アンユージュアル エスケープ” to be inserted as “???? ??? ????? ???”.

What Navision does is convert this string to a series of Non-Unicode bytes like “ƒAƒ“ƒ†[ƒWƒ…ƒAƒ‹@ƒGƒXƒP[ƒv"

After some time figuring out how to insert these Unicode strings into NAV we came up with the following.

Step 1: Determine the codepages

First of all you need to determine the codepages the server and NAV use. In my case the server was running codepage 1252 Latin encoding. And NAV, because of the Non-Unicode settings, was running under codepage Japanese Shift-JIS (932).

Step 2: Convert your strings

So now you know what codepages you use, the solution is actually pretty straight-forward. What does NAV do? Well, when you input this Japanese string 日本 アンユージュアル エスケープ in NAV. Navision is running codepage 932 and gets the Bytes for this string in 932 encoding. The OS is running codepage 1252 so the SQL server also uses this codepage. What you need to do is convert these 932 bytes into a 1252 encoded string.

The following C# code will do this for you. Remeber to replace the 932 and 1252 encodings with your encoding.

string JapString = "日本 アンユージュアル エスケープ";
string NavString = "";
Encoding nav = Encoding.GetEncoding(1252);
Encoding unicode = Encoding.GetEncoding(932);
byte[] unicodeBytes = unicode.GetBytes(JapString);
NavString = nav.GetString(unicodeBytes);

now the NavString variable contains “ƒAƒ“ƒ†[ƒWƒ…ƒAƒ‹@ƒGƒXƒP[ƒv”.

Great!!

 
2 Comments

Posted by on June 15, 2009 in .NET, NAV

 

Tags: , ,

NAV vs DBCS

We recently faced a challange to setup bussiness in Japan. We all know that NAV is NOT Unicode and therefore it does not support the Japanese characterset which is a DBCS.

How do we proceed in this case? What are the steps needed to get the NAV database up and running?
These were just some of the questions I had. There wasn’t much information I could find on the net regarding this issue. Having some support calls logged with MS helped solve alot of issues.

Anyway, in this post I will share with you all how we were able to make this installation successfull.

What is DBCS?

DBCS stands for Double Byte Character Set. In CJK (Chinese, Japanese and Korean) computing, the term “DBCS” traditionally means a character set in which every graphic character not representable by an accompanying SBCS is encoded in two bytes; Han characters would generally comprise most of these two-byte characters.

The NAV STX file:

The first thing you need is a new stx file which has been sealed with the “Allow DBCS” switch on.

// The following entry is for double-byte character set (DBCS) clients (code  pages 932, 936, 949, 950)   
// A value of 0 indicates that a client DBCS is disallowed   
// A value of 1 indicates that a client DBCS is allowed, provided that the database code page is a non-DBCS code page   
00093-00400-010-2: 1 

Sealing this stx file can only be done by microsoft. Send them your STX file and you will receive a new one with DBCS enabled.

The Japanese Language pack:

The next step will be to install the Japanese language pack. There is NO official language pack from Microsoft available. You will need to contact a local solution center in Japan to obtain it. This language Pack will have all the menu items, forms and tables translated.

Now you can try and open NAV. If the database server is running on a English OS using the 1252 latin codepage, you will NOT see any japanese characters. The only thing you will see are meaningless ASCII sings. To be able to see the Japanese text, you will need to set the regional settings for the server.

Regional Settings:

Go into the control panel > Regional and Language Options.
In here you need to Install Files for East Asian Languages in the Languages tab. (This will enable the OS to display Japanese text in menus)
Next up is setting the language used in Non-Unicode applications, such as Navision.
Set this selection to the Language needed for the NAV database. In my case this was Japanese.

Finished!

After this you will be able to display the Japanese characters in NAV.
The data which is in SQL however, is still displayed in this ASCII sequences. It is Windows who actually converts these ASCII characters into the correct Japanese character because of this Non-Unicode app setting.

 
5 Comments

Posted by on June 8, 2009 in NAV

 

Tags: ,

 
Follow

Get every new post delivered to your Inbox.