-
1. Re: ESTK string bug [CS5, CS5.5]
cweger79 May 6, 2011 8:07 AM (in response to cweger79)Actually, never mind. I've done some web surfing and discovered that JavaScript and binary data do not, in general, get along very well at all.
There's some hope for browsers -- for example, Mozilla has typed arrays (https://developer.mozilla.org/en/JavaScript_typed_arrays) -- but old school JavaScript/ECMAScript like the version in ESTK just won't work with this.
So I'll go off and do what I need to do in C.
HOWEVER, my bug report still stands. I don't think the IDE should crash when encountering this situation.
Regards,
Chuck
-
2. Re: ESTK string bug [CS5, CS5.5]
John Hawkinson May 6, 2011 11:41 AM (in response to cweger79)The ESTK does weird things if the Javascript engine crashes. Certainly that shouldn't happen, and you should submit a bug report, either through a support channel or to adobe.com/go/wish. But I think the bigger issue is the Javascript engine crashing.
That said, I suspect you're mostly fine with binary data in strings as long as you don't call certain kinds of functions. Somehow I'm not surprised that the fromCharCode methods kills everything...
-
3. Re: ESTK string bug [CS5, CS5.5]
John Hawkinson May 6, 2011 11:10 PM (in response to John Hawkinson)However, I am a bit more disturbed that this program causes a similar hang:
//var s = String.fromCharCode(65, 66, 67, 68, 69); var s= "\u0041\u0042\u0000\u0044\u0045"; $.writeln("string len=" + s.length); for (var i=0; i < s.length; i++) { //$.writeln("#" + i + " = " + s.charCodeAt(i)); $.writeln("mystery"); } s="cheese";So, it's not even necessary to index into the string to cause the problem, nor is it the fromCharCode or charCodeAt methods.
-
4. Re: ESTK string bug [CS5, CS5.5]
Marc Autret May 7, 2011 4:10 AM (in response to cweger79)Same result in WinXP + ESTK CS5.
Just needed to inject a \x00 in a literal string to crash ESTK.
Minimal code tested:
var s= "\x41\x42\x00\x44\x45";
Result in the data browser: s is undefined —while ESTK CS4 displays 'AB'.
@+Marc
-
5. Re: ESTK string bug [CS5, CS5.5]
cweger79 May 9, 2011 6:32 AM (in response to Marc Autret)"AB" is what I would expect, assuming the JavaScript engine is using C-style null-terminated strings. I still pine for binary data, though.
-Chuck
-
6. Re: ESTK string bug [CS5, CS5.5]
SlavaBuck Nov 17, 2013 3:00 PM (in response to cweger79)I'm found only one safe way to use binary data in strings with ESTK:
Do not use a direct assignment binary data to any variable in the body of the script, but you can get its as function result or put it as a function argument directly:
var s= "\x41\x42\x00\x44\x45"; // cause problems
but
var s = function() { return "\x41\x42\x00\x44\x45....." }; // not cause problems!!!
and then use s() anywhere;
or
var s = ScriptUI.newImage ("\x41\x42\x00\x44\x45....."); // for embedding image...
P.S.
sorry for my english, I use google translate something where


