开发者

Using eclipse on Mac OSX, I get random invisible character \160 . Why?

I'm using Eclipse on Mac OSX and I randomly get character \160 (whatever that is) instead of a whitespace in my code.

From time to time when I compile I get this error:

java:74: illegal character: \1开发者_如何学Go60

if (c == '*' ||?c == '/')

when my code in Eclipse actually looks like:

if (c == '*' || c == '/')

This is annoying and usually resolved by deleting the supposed invisible ? and pressing spacebar once again in the editor.

I'm curious as to why this happens if anybody has an idea.


as @Hanynowsky mention it is related to a different encoding between the source you copied and the one from your file. I have not found any way to automatically removed the bogus mismatching characters, but you can actually see them in eclipse if you enable the editor to show whitespaces.

For doing that:

  • set Eclipse to "show whitespace characters" (option under Preferences -> General -> Editors -> Text Editors)
  • the bogus \160 character will appear as " ." even if your other spaces will appear as ".". So you just need to delete the " ." occurrences and you are good!


When you copy / paste a code from a website page into your IDE editor, you might get this error as the copied code has invisible unknown characters, usually white spaces. Unfortunately I do not know of any solution bar to remove and re-ident every white spaces between your code's identifiers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜