Reputation: 4421
When I copy paste code into Android Studio sometimes (from WEB or other external source) I get some unvisible characters and I can't compile. Is there a way to avoid this? Reformat code automatically? Plugin? Change settings?
Error:(40, 61) error: illegal character: \8232
So far I delete the code any type it in by hand again.
Upvotes: 7
Views: 4991
Reputation: 1013
@Rock Lee
After you open
SystemPreferences>Keyboard>InputSources
or
Upvotes: 0
Reputation: 9566
I used this site (https://r12a.github.io/apps/conversion/), copied and pasted my code surrounding where the invisible error was, and pasted it into the top box right under the button "Convert."
Then I copied and pasted the result code that was automatically generated in the box under the title "Unicode U+hex notation", and noticed it had something like this:
//Remove the last 2 characters (The last ", ").
U+2028title.substring(0, title.length() - 2);
return title;
I just deleted the U+2028
and pasted that code back into Android Studio, and it compiled.
Upvotes: 0
Reputation: 4077
\8232 is decimal for U+2028
on a Mac, it usually gets into IntelliJ/AndroidStudio when text is copied and pasted from Notes
in System Preferences, open Keyboard/Input Sources and add Unicode Hex Input
in IntelliJ/AndroidStudio, open Edit/Find/Replace and type 2028 while holding Option key, then click Replace all
Upvotes: 1
Reputation: 7156
I believe your file encoding is windows-1252 (bottom right corner in AS)? Here is a Blog about file encoding. I also use UTF-8 for everything. Blog about file encodings in IntelliJ
Since AS is IntelliJ-based, this also applies to AS.
Upvotes: 1