locked
Read and write Japanese characters in oracle DB using Asp.net application RRS feed

  • Question

  • User-339624306 posted

    Hi,

    We have oracle DB(10g) with western european character set(WE8ISO8859P1).we have datatypes Varchar and Clob.Our application is developed in ColdFusion and its working fine for Japanese characters (Both Read and write).Now we migrated our coldfusion application into Dotnet.Now we have problem with japanese character read and write.

    we have tried different methods.

    1.If the DB characterset is UTF-8 It will work fine for both Coldfusion and DotNET

    But we cannot change the characterset because it might corrupt the old datas(we have millions of old records)

    2.If we change the datatypes to nvarchar and nclob with the same western european character set(WE8ISO8859P1).it will work fine for Dotnet as well as Coldfusion,

    if the records are inserted newly.But its not supporting the records which has already  inserted using Varchar and Clob datatypes using coldfusion application.

    So can anyone give idea about how to handle this without changing the DB character set and Datatypes..

    Thanks&Regards,

    V.Vinil Bradesh




    Wednesday, July 8, 2009 2:42 AM

Answers

  • User401360897 posted

    how to handle this without changing the DB character set and Datatypes.

    I think you need to Add a new Field in Database with nvarchar Data Type and Copy all values of your Old Field in to this new Field(Use UTF8 Encoding while Copying using SQL).

    Another way which work for only new values is to use Given Code,


    byte[] b = System.Text.Encoding.UTF8.GetBytes("цял");
            string s = "";
            for (int i = 0; i < b.Length; i++)
                s += b[i].ToString() + "|";
            //Save s in Database
            Response.Write(s + "<br>");
    
            //Retrieve s from Database
            string[] s1 = s.Split('|');
            byte[] b1 = new byte[s1.Length - 1];
            for (int i = 0; i < s1.Length - 1; i++)
                b1[i] = byte.Parse(s1[i]);
            string s2 = System.Text.Encoding.UTF8.GetString(b1);
            Response.Write("цял" + "<br>");
            Response.Write(s2+"<br>");


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 9, 2009 12:34 AM

All replies

  • Wednesday, July 8, 2009 7:07 AM
  • User-339624306 posted

    Hi Kamran Shahid,

    Thanks for your Reply.

     The link you have given is posted by our Team.It  haven't help us..


    Wednesday, July 8, 2009 9:54 AM
  • User401360897 posted

    how to handle this without changing the DB character set and Datatypes.

    I think you need to Add a new Field in Database with nvarchar Data Type and Copy all values of your Old Field in to this new Field(Use UTF8 Encoding while Copying using SQL).

    Another way which work for only new values is to use Given Code,


    byte[] b = System.Text.Encoding.UTF8.GetBytes("цял");
            string s = "";
            for (int i = 0; i < b.Length; i++)
                s += b[i].ToString() + "|";
            //Save s in Database
            Response.Write(s + "<br>");
    
            //Retrieve s from Database
            string[] s1 = s.Split('|');
            byte[] b1 = new byte[s1.Length - 1];
            for (int i = 0; i < s1.Length - 1; i++)
                b1[i] = byte.Parse(s1[i]);
            string s2 = System.Text.Encoding.UTF8.GetString(b1);
            Response.Write("цял" + "<br>");
            Response.Write(s2+"<br>");


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 9, 2009 12:34 AM