0

Our editors upload content to our database via a admin panel. however they copy the text directly from MS Word which is where i suspect this problem is coming in. however the admin panel was developed by another developer and i dont have the means currently to update it.

When i pull a title from the database it displays as:

Google’s instead of Google's

My Charset

<meta charset="utf-8">

My section of the controller where i retrieve the data:

 $article = Article::where('id', $article_id)->first();
 return view('articles.view')->with('article', $article);

Displaying the data in my blade file:

{!! $article->title !!}

I had a previous StackOverflow question about this matter: PHP: getting “SSA's” instead of “SSA's”

Iv tried the answers from the above but no luck.

{!! html_entity_decode( $article->title ) !!}
{!! htmlspecialchars_decode( $article->title ) !!}

any help regarding this issue would be appreciated.

Community
  • 1
  • 1
  • Is your database collation UTF8? Are your database tables UTF8? Is your [database connection UTF8](http://stackoverflow.com/q/32867172/247893)? Is your `content-type` charset UTF8? Are your PHP files saved as UTF8? If in doubt, please read [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through). – h2ooooooo May 19 '16 at 11:56
  • Its saving to the database as "Africa’s" instead of "Africa's" - the database wasnt setup by me and we cant alter just yet because the main site is using it. im rebuilding another version but was hoping there was a code fix for this @h2ooooooo –  May 19 '16 at 12:00
  • Have you tried specifying the encoding in `html_entity_decode`? (it should match that of the database) – h2ooooooo May 19 '16 at 12:01
  • Yeah, unfortunately no luck –  May 19 '16 at 12:04
  • I don't use laravel but I'd start backtracking. You've acknowledged that the issue is happening through your blade file. What if you print it directly in the controller hence avoiding the blade file? (using `var_dump`) What if you fetch the value directly from the DB and print it then? (Is it the DB layer that has an issue?) What if you try different encodings with `html_entity_decode`? (Is it your encoding that's an issue?) What charset is your database compared to laravel? – h2ooooooo May 19 '16 at 12:06
  • I know you said you've tried `html_entity_decode`, but would you run it through with these settings and see if it makes a difference? `html_entity_decode($string, ENT_QUOTES, 'UTF-8')` – Samsquanch May 19 '16 at 12:33
  • If it's being weird when it's inserted into the database, there are three things I can think of right off the bat: PHP headers, connection-charset and/or table/database charset (collation isn't the same as charset). When dealing with charsets, you should set the same charset on everything, across your application, or you may end up with broken characters like that. – Qirel May 19 '16 at 12:35
  • @Qirel But according to OP "*Its saving to the database as "Africa’s*" that *does* translate to `Africa’s` when using `html_entity_decode`. There's some encoding stuff going on somewhere in the getting/outputting process. – h2ooooooo May 19 '16 at 12:41
  • You are indeed right, @h2ooooooo - I didn't quite read that comment. :) – Qirel May 19 '16 at 12:44

0 Answers0