Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 japanese chars as ??? using japanese collation

Author  Topic 

ivan.rachev
Starting Member

4 Posts

Posted - 2008-10-03 : 11:03:29

Hi,
I have MS SQL 2005. I tried all Japanese collations and none of them can store JIS X 0212:1990 characters (http://en.wikipedia.org/wiki/JIS_X_0212). Yet, they can all store JIS X 0208. What is the problem? Do I need an extra package that is not provided in a standard MS SQL installation ?

Ivan

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-10-03 : 11:18:52
I don't know anything about it but reading the link you provided - This "Japanese industrial standard" uses 3 bytes per character! (unicode uses 2 bytes) It also said: "Apart from the applications mentioned above, the JIS X 0212 standard is effectively dead". The applications mentioned above did not include MS Sql Server. So it doesn't look promising

Be One with the Optimizer
TG
Go to Top of Page

ivan.rachev
Starting Member

4 Posts

Posted - 2008-10-03 : 11:45:53
It is not promising. That's why I'm posting: to get the opinion of people that KNOW something about it because there is probably a solution. I doubt there is no way to store these characters in Japan.

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-10-03 : 12:23:09
if they use 3 bytes per char then your only solution would be to hack something with varbinary datatype... i have no clue on how to do that exactly, tough

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-10-03 : 13:05:34
I know you only want to hear from people that KNOW something but I'll risk your wrath by posting a question - 'cause I'm curious: What is the source of your JIS X 0212:1990 data?

I'm also curious if Arnold F pipes in with anything - this sounds like an area he may know something about...

Be One with the Optimizer
TG
Go to Top of Page

ivan.rachev
Starting Member

4 Posts

Posted - 2008-10-06 : 14:02:07
The Japanese healthcare industry uses this code page to transfer information between hospitals. I get this information from MRI scanners and I need to store it in the db. I use Japanese_90_CI_AS collation. It successfully stores JIS 0208 but not JIS 0212. If Arnold F knows anything about this, he's welcomed to share it.

Ivan
Go to Top of Page

ivan.rachev
Starting Member

4 Posts

Posted - 2008-10-08 : 11:52:24
here is a piece of C# code that exposes the problem.
The app saves a string to the database, retrieves it, then compares the two. They turn out to be different.

using System;
using System.IO;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;

namespace JIS_0212
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
string dataIN = "\u4F3B\u56E6\u8835(JIS_0212)\u96E3\u8AAD\u6F22\u5B57(JIS_0208)";
string dataOUT = "";
string dbUser = "$USER_NAME_TO_CONNECT_TO_DB$";
string dbPassword = "$PASSWORD_TO_CONNECT_TO_DB$";
string dbName = "master";

SqlConnection conn = new SqlConnection();
conn.ConnectionString =
"Data Source=127.0.0.1,1433;Network Library=DBMSSOCN;Initial catalog=" +
dbName + ";user id=" + dbUser + ";password=" + dbPassword + ";pooling=false";
conn.Open();
SqlCommand command = new SqlCommand();
command.Connection = conn;
command.CommandType = CommandType.Text;
command.CommandText =
"if not exists (select * from sys.objects " +
" where object_id = object_id(N'[dbo].[JIS_0212]') and " +
" type in (N'U')) " +
"begin " +
" create table JIS_0212 (data varchar(64) collate Japanese_90_CI_AS) " +
"end " +
"insert into JIS_0212 values (N'"+ dataIN +"') " +
"select * from JIS_0212";
SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
dataOUT = reader.GetString(0);


string s = "JIS_0212";
string dataIN_0212 = dataIN.Substring(0, dataIN.IndexOf(s) + s.Length + 1);
string dataOUT_0212 = dataOUT.Substring(0, dataOUT.IndexOf(s) + s.Length + 1);
if (dataIN_0212 == dataOUT_0212)
Trace.WriteLine("JIS 0212:1990 stored successfully :)");
else
Trace.WriteLine("JIS 0212:1990 data mismatch in DB :(");

string dataIN_0208 = dataIN.Substring(dataIN.IndexOf("JIS_0212") + s.Length + 1);
string dataOUT_0208 = dataOUT.Substring(dataOUT.IndexOf("JIS_0212") + s.Length + 1);
if (dataIN_0208 == dataOUT_0208)
Trace.WriteLine("JIS 0208 stored successfully :)");
else
Trace.WriteLine("JIS 0208 data mismatch in DB :(");
}
catch (Exception e)
{
Trace.WriteLine(e.ToString());
}
}
}
}
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-10-08 : 12:07:53
as we said since you can't store 3 bytes per character fully in a max 2 bytes per character datatype fully in sql server.
have you tried the using varbinary?


_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-10-08 : 13:41:15
According to the article:
"Apart from the applications mentioned above, the JIS X 0212 standard is effectively dead. 2,743 kanji from it were included in the later JIS X 0213 standard. In the longer term, its contribution will probably be seen to be the 5,801 kanji which were incorporated in Unicode."

Since these characters are available in Unicode, you may be able to use SQL Server unicode datatypes to store it (NCHAR, NVARCHAR, etc.) You may have to do some work on the front end to translate your data into unicode.



CODO ERGO SUM
Go to Top of Page
   

- Advertisement -