Unexpected token: Error: (40, 61) error: illegal character: \ 8232 in Android Studio

When I sometimes copy code in Android Studio (from WEB or another external source), I get several invisible characters, and I can not compile them. Is there any way to avoid this? Reformat code automatically? Plugin? Change settings?

Error:(40, 61) error: illegal character: \8232 

Until now, I am deleting the code again with any type in my hand.

+7
android studio
source share
4 answers

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. IntelliJ File Encoding Blog

Since AS is an IntelliJ base, this also applies to AS.

+1
source share

\ 8232 is decimal for U + 2028

on a Mac , it usually gets into IntelliJ / AndroidStudio when copying and pasting text from Notes

in System Preferences , open Keyboard / Source Sources and add Unicode Hex Input

in IntelliJ / AndroidStudio , open Modify / find / replace and enter 2028 while holding down the Option key then click Replace All

+1
source share

I used this site ( https://r12a.imtqy.com/apps/conversion/ ), copied and pasted my code where there was an invisible error, and pasted it to the beginning on the right under the "Convert" button.

Then I copied and pasted the result code, which was automatically generated in the field under the heading "Unicode U + hex notation", and noticed that it has something like this:

 //Remove the last 2 characters (The last ", "). U+2028title.substring(0, title.length() - 2); return title; 

I just uninstalled U+2028 and pasted this code back into Android Studio and compiled it.

0
source share

@Rock Lee

After opening

 SystemPreferences>Keyboard>InputSources 
  • click the + sign, then in the Search field below enter Unicode

or

  • scroll to the end of the list of languages ​​to "Other", where it is also listed.
0
source share

All Articles