Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Backslash-apostrophe POOF.
July 26, 2008, 2:49 am
rate this thread
submits it to a server. Yet another social bookmarking application.
I'm having trouble with page titles that include an apostrophe.
I'm using encodeURIComponent() around the page title, and again around
the URL. Apparently the browser is inserting a backslash before any
apostrophe. I can see that when I write the $_GET data to a file in
PHP on the server. When the GET data is processed, PHP generates a
page with a form, and the data is plugged into some input fields. The
page is sent to the user's browser for editing and approval, and
there's where the problem shows up. Here's the transformation...
Say we have a page with the title "Here's the page" (minus the
Page title: --> Here's the page // the title gets
PHP gets --> Here\'s the page // a backslash gets
HTML form --> Here\ // truncated!
I don't know why this is happening, or what to do about it. I tried
using PHP stripslashes() and that doesn't do it. What do I need to
Re: Backslash-apostrophe POOF.
It's trickier than that! Simply using stripslashes() solved the
backslash+apostrophe issue, but then I tried it on a page title with
some HTML entities in it, and once again, there was a truncation at
the first '<' character. So... using your code solved that one. Until
I had a title that was in Japanese, which gave no problem until I
started fixing this. That one renders the UTF codes, not the
characters as before.