JSLint "Unsafe character"
I was happily using Douglas Crockford's JSLint on Mac OS X and my code passes, but after I got a Ubuntu Hardy Slicehost server and uploaded my code there, the JSLint no longer passes when I try to run it on the server. It fails on my localized files that contain umlauts.
I get errors like:
Lint at line 1206 character 25: Unsafe character.
"PREVIOUS" : "zur??ck",
Lint at line 1207 character 26: Unsafe character.
"NEXTPAGE" : "vorw??rts",
The file hasn't chang开发者_如何学Ced, I checked the MD5 hash and they are same on both. This is how I run JSLint from my deployment script:
def lint_ok(fn):
return os.system("java org.mozilla.javascript.tools.shell.Main jslint/jslint.js %s" % fn) == 0
Any ideas? What could be different? I checked the environment (env / set) and the only reference to character sets / encodings was "LC_CTYPE=UTF-8". I tried setting it to be the same but it seemed to have no effect.
For your question this may be related to "unsafe characters". See JsLint documentation
There are characters that are handled inconsistently in browsers, and so must be escaped when placed in strings.
I'm running into a similar problem although it appears the BOM mark at the start of the file prevents JsLint going further.
There is a bugfix here for some java port of JsLint that addresses this issue.
精彩评论