Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

’ is being displayed instead of -

’ is being displayed instead of - in php page

I tried using different encoding types like:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>

and

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

but result is the same. What could be the problem?

Input

<strong style="color:#A8A8A8;">1</strong> – Lorem Ipsum.

Result

1 – Lorem Ipsum.

like image 490
jeevan Avatar asked Apr 04 '13 10:04

jeevan


People also ask

What does â € mean in HTML?

If your database contains ’ , then it's your database that's messed up. Most probably the tables aren't configured to use UTF-8 . Instead, they use the database's default encoding, which varies depending on the configuration.

Why is â showing up?

Getting weird characters like  instead of or ’? Most likely there is a Character set problem. It can occur when a MySQL and PHP are upgraded or when data has been incorrectly stored or the application is sending an incorrect (or missing) character set to the browser.

Why does É become Ã?

The reason lies in the UTF-8 representation. Characters below or equal to 127 ( 0x7F ) are represented with 1 byte only, and this is equivalent to the ASCII value.

What garbled characters?

Mojibake (Japanese: 文字化け; IPA: [mod͡ʑibake]) is the garbled text that is the result of text being decoded using an unintended character encoding. The result is a systematic replacement of symbols with completely unrelated ones, often from a different writing system.


1 Answers

Make sure your html header specifies utf8

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

That usually does the trick for me (obviously if the content IS utf8).

You don't need to convert to html entities if you set the content-type.


check http://php.net/manual/en/function.mb-convert-encoding.php

<?php
     header('Content-Type: text/html; charset=utf-8');
     mb_internal_encoding('utf-8');
?>

may be this will help you.

like image 95
Tony Stark Avatar answered Sep 22 '22 12:09

Tony Stark