0

So in latvian language there are a lot of special letters like - ē ā š ņ č and much more. I have a problem where when i am putting info from textarea in to a database letter "š" and in database its writing "&S caron;" instead of letter what i need. But most interesting is when i try to output files in blade. In blade where im putting out all the posts, text is showing this "&S caron;" instead of "š" but when i open single post page it displays text correct. I have set charset uft-8 in my header and for DB i allready tried utf8mb4_latvian_ci utf8mb4_unicode_ci and utf8_unicode_ci

here is some screens

DB screen

How displays text where all posts displaying

How displays text in single post page

If there is need for some code fragments please ask because i dont even know where to dig...

There is situation where in one table in different fields encoding is same and inputting letter "š" in field "post title" it shows correct but in field "post body" its showing "&S caron;". And it is same showing in browser in all posts page - title correct and post text going with "&S caron;" and in single post page all is correct. kinda confused....

So i tried to put correct text in DB manual via phpmyadmin and now that post body is showing correct and in blade that post shows correct but others not. so i guess there is problem with inputing info

Karlis Pokkers
  • 224
  • 5
  • 18
  • 1
    While you’re correct that your database needs to have the correct encoding to store the character, `Š` is an HTML encoding of the character. It has nothing to do with your database. You’ll need to convert that HTML code into the actual character. This post may help you convert the HTML encoded character to the actual Latvian letter before storing it in your database. https://stackoverflow.com/q/2651711/10068463 – Nate Mar 02 '19 at 16:48
  • If your issue is how it’s displaying on the website then you’ll need to make sure that you aren’t double encoding the text. Because what you currently have should work fine but I bet if you look at your HTML that’s being output, you’ll see `&Scaron;` instead of `Š`. You have to tell it that the text you’re displaying is safe and doesn’t need to be HTML encoded, otherwise special characters like <>& will become HTML encoded. Making it output the text as is without html encoding does leave you vulnerable to people adding actual code in content if this text is from user input though. – Nate Mar 02 '19 at 16:53
  • So that was a long-winded way of saying that you either need to store the HTML unencoded value, so that it can safely encode (without doubling up the encoding), or store the encoded value and skip encoding on output (which is fine as long as you trust the person storing this content, but it’s not best practice). – Nate Mar 02 '19 at 16:57
  • Most likely the browser is submitting the character HTML-encoded because it is not properly aware that it should submit it as UTF-8, likely due to missing encoding-related declarations on your part. – deceze Mar 02 '19 at 19:35

0 Answers0