0

i try to load this url into my webview : https://fr.wikipedia.org/wiki/Abbaye_d'Engelberg but it dont work cause it contains ' character how can i fix it please?

3 Answers 3

4

Please put the url like below

https://fr.wikipedia.org/wiki/Abbaye_d%27Engelberg

url encoding for ' is %27

1
  • it worked with url = url.replaceAll("\'","%27"); thanks rep++
    – Noj
    Nov 26, 2015 at 18:40
1

Just put a backslash: Eg. Load the url https://fr.wikipedia.org/wiki/Abbaye_d\'Engelberg

Note the backslash before the ' character.

3
  • i already tried it with myurl.replaceall but i didn't managed to get it working, what is the pattern to doit? all other special char seems to work
    – Noj
    Nov 26, 2015 at 18:26
  • @Noj I'm a little rusty in java, but it would be something like this: myUrl.replaceAll("\'", "\\\'") Though if you are loading a String variable it should work. When you say it doesn't work, does it crash?
    – Nathan
    Nov 26, 2015 at 18:29
  • @Noj If the app crashes then please post the logcat info
    – Nathan
    Nov 26, 2015 at 18:30
0

I have also faced this issue, in android-webview ( react-native ) so to fix this I have used ...

document.replace(/\'/g, "\\\'")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.