Hello.

 

I have a problem. 

 

I use the SetB and the GetB function to send and retrieve data from C# to J 
(and vice-versa). The problem is, J trashes the Unicode strings whenever I pass 
it a Unicode data. Take the following C# code (please note that I am using the 
JSoftware.Session library that can be found in à JSoftware Wiki 
<http://www.jsoftware.com/jwiki/bathala?action=AttachFile&do=get&target=J_NET.zip>
 ):

 

using System;

using System.Collections.Generic;

using System.Text;

using JSoftware;

 

namespace UnicodeTest

{

    class Program

    {

        static void Main(string[] args)

        {

            // Create an instance of a J Session with debug mode on (display 
the J session window)

            JSoftware.Session jSession = new JSoftware.Session(true);

            // This is a Simplified Chinese set of characters

            string strTest =  "对最后问题的答复。";

            object[,] test = new object[2,2];

            // Assign 42 and the chinese script to the first row

            test[0, 0] = 42;

            test[0, 1] = strTest;

            // Assign 0 and an ASCII string to the second row

            test[1, 0] = 0;

            test[1, 1] = "This is a test";

            // Send the array to J using the SetB function

            jSession.Variable("test1", test);

            // Print out the result in the J Session

            jSession.Eval("test1");

        }

    }

}

 

When you execute this, the result is:

   NB. Have fun! - bathala <[EMAIL PROTECTED]>

   test1

┌──┬──────────────┐

│42│ 
T [1]     │

├──┼──────────────┤

│0 │This is a test│

└──┴──────────────┘

   

As you can see, the Unicode string is trashed but the ASCII is ok. 

 

I have looked at Oleg’s discussion with Unicode string and J 
<http://www.jsoftware.com/jwiki/Guides/.NET_Interop#head-dfa1a49795479b47f02c6c0a7fe408a9096e83c1>
  but unfortunately this wouldn’t work for me because I would need to 
concatenate and do some other manipulation to the strings in J before returning 
them to .NET for updating the GUI and saving to the DB. Also, if I use Oleg’s 
strategy, I would have to treat every string that I pass on to J as a byte 
array ... which again wouldn’t work for what I need. So does anybody have an 
idea on how I can pass J a heterogeneous tables where each column may be 
numeric or a Unicode string. 

 

Thanks, I appreciate any help. J

 

r/Alex

 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to