views:

354

answers:

1

I am using these 2 functions:

http://javascript.about.com/library/bladdslash.htm

But JSLint complains 'Bad Escapement' on this line:

str=str.replace(/\\0/g,'\0');

[Edit]

I converted to 2 lines, and now the first line is the one that fails JLint:

var rep = '\0';
str=str.replace(/\\0/g,rep);

So it is the

'\0'

can you help? I could try something but I want to understand what is going on.

[/Edit]

Can you make a better version and explain?

I would like a version that passes JSLint and still works.

+1  A: 

Replace '\0' with String.fromCharCode(0).

Alternatively, if you don't expect your data to contain embedded nulls (which it really shouldn't), you can remove that line entirely.

SLaks