This project has moved and is read-only. For the latest updates, please go here.

Null characters in strings not passed between host and script

Apr 6, 2014 at 10:45 AM

It seems that null characters in strings, that are valid in both .Net and JavaScript, are not passed between host and script in both directions.

For example:
class StringTest
        public static int GetLength(string s)
            return s.Length;


engine.AddHostType("Console", typeof(Console));

// Test JS string passed to host
engine.AddHostType("StringTest", typeof(StringTest));

var jsString = 'ab\0cd';
Console.WriteLine('JS length of jsString {0}', jsString.length);
Console.WriteLine('Host length of jsString: {0}', StringTest.GetLength(jsString));

// Test Host string passed to JS
string hostString = "ef\0gh";
Console.WriteLine("Host length of hostString: {0}", hostString.Length);
engine.Execute("function jsLength(s) {Console.WriteLine('JS length of hostString: {0}', s.length);}");
The output I get is:

JS length of jsString 5
Host length of jsString: 2 <---- Wrong, should be 5
Host length of hostString: 5
JS length of hostString: 2 <---- Wrong, should be 5

Thanks in advance,
Apr 7, 2014 at 4:07 AM
Hi Ron,

You're right. A fix is on the way.

Apr 10, 2014 at 12:59 PM

The fix is now available.

Thanks again!
Marked as answer by Zcodez on 4/15/2014 at 8:03 AM