• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Does Android Studio provide a way to escape strings?

Stokestack

Lurker
I have a long string, and the compiler's complaining that there are unescaped apostrophes in it.

This seems like the kind of thing Android Studio should offer as a function: Escape this string.

Does it?
 
The question is whether Android Studio provides a function to escape all necessary characters in a string at once, so you don't have to go through paragraphs of text and do it manually. Does your response answer that question?
 
I don't think I've seen any IDE which can automatically detect and escape single-quotes for you - if you know of one, please let me know so I can check it out.

At any rate, I wasn't able to find anything in Android Studio to do that. I think you'll have to manually escape naughty characters by preceding them with a backslash, like @wseng92 suggested.
 
Thanks. I'm not expecting anything automatic. I just want to highlight a block of text and then hit a hotkey or go to a menu and say "Escape string."
 
I'm not a dev myself of course and I've never used AS, but does the code editor in Android Studio not provide a global "FIND > REPLACE" function, like just about all decent word-processor and text editing software has? Where you can set it to find a specific string of characters and have it automatically replace them with something else, i.e. have it search your code and FIND these "unescaped apostrophes" and it REPLACE with the your appropriate escape string or whatever.
 
It does, but then you have to try every possible illegal character and do a global replacement for each one. It's not just apostrophes.
 
Back
Top Bottom