When I pass a string with special characters to my view, The special characters are shown as a question mark, eg:
$data['make'] = 'Quels pneus Dunlop avez-vous acheté ?';
$this->load->view("form", $data);
This looks as follows in my view:
When I type the characters directly into the HTML page they show fine. how can I fix this issue?
EDIT: The charset is already set to:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Using codeigniters ascii_to_entities function did the trick.
$this->load->helper('text');
ascii_to_entities($string);
Looks like it could be a charset conflict. Make your HTML charset declaration UTF8 and save your data as UTF8 in the database or text file.
In your <head> tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
If you are using htmlentities() to output the data var then consider specifying the character set there as well.
echo htmlentities($str, ENT_COMPAT, 'UTF-8');
Save your view page as utf8 and that will do the job
Related
I've got a problem with my charset I guess.
I've called out this line of code on the top of my file.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
when I try to read out an 'ë' it returns these two characters: ë .
I can't figure out what I have to do, to return the accented character.
I also found out it only happens to be when I put the accented character into <h1> tags.
Try adding this extra tag so it looks like this:
<meta charset="UTF-8">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
If the data is in a file (I guess an html file) then this may help: http://www.thedatastudio.net/character_encoding_profile.htm.
What are you reading the file with? As you suggest, I'm sure it's interpreting the file as if it were in a different character encoding.
If you are reading data from mysql database then you can use mysqli_set_charset() for mysqli or if you are using PDO you can try below code.
$dbh = new PDO('mysql:'.$conn, $username, $password);
$dbh->exec("set names utf8");
My website is replacing an apostrophe (') with a question mark (?) while rendering the page.
See the deal - my kitchen cook's at
www.dealschintu.com
It is a simple HTML page written by me which does the following
Connect to MySQL database
Retrieve title
Display
Add this between the <head> tags of your website:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
It should do the trick.
I got it working by changing the php file encoding from utf-8 to iso-8859-1
I used spanish language in my site. when iinserted the character like í,á,é,ó it will insert properly in db,but it cannot display in front-end, it display like this � in front-end
for example :
Insert name : Test teachér in database it inserted correctly but in front it display as
Test teach�r.
i used <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
also but no changes at all.
It has nothing to do with smarty.
Check db charset where you store data and set it to UTF-8 General CI
Check charset of db connection SET NAMES utf8
Check the output of script if it's in UTF you can do it with meta charset, or in headers content-type.
Content-type: text/html; charset="UTF-8"
or
<meta charset="utf-8"> or <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
After these operations you should have proper output.
You can also optionally check if functions that work on strings supports UTF-8.
fm API to get event discription, venue name etc...
Now sometimes I get special chars back like: ' é à , but they show up scrabled.
So how can I display them properly? Also with the descrioption I get html-tags back, but I do want to keep these.
Can someone help me out fot those both cases? The language I'm using is php
Thanks in advance
specify encoding in the header:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
...
encode string when handling the input
$str=utf8_encode($str);
if you are displaying the input back as-is, no encoding is required;
however, if the value is the content of an input or textarea, escape the html characters
<?php echo htmlspecialchars($str); ?>
For Latin characters, use
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
in your section.
you need to be sure about two things, the meta header referring to which enconding you will be using, and the encoding you are using for the text served.
If you are using a utf8 header just be sure to convert the text served to utf8, refer to functions for encoding conversion like : mb_convert_encoding
I'm trying to print a string, like this:
Noticias de Fútbol.
But when I print this string, it displays like this:
Noticias de F�tbol.
I tried htmlspecialchar() and many more, but my output remains the same.
$str = "Noticias de Fútbol";
$strfoot = html_entity_decode($str);
How can I resolve this?
You don't need to use html_entity_decode, you can just simply print out your $str with echo, but you have to make sure your html has this line of code in the <head>:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
You have use charset utf 8 and htmlentities function of php
Like
<meta http-equiv="content-type" content="text/html; charset=utf-8">
$test=htmlentities("Sisälämpötila");
echo $test;
You are most likely outputting to a page that has the wrong charset specified. To confirm this open a JavaScript console and evaluate window.document.charSet and window.document.characterSet.
If that is the case you can use a meta tag to inform the browser of your intended charset:
<meta content="text/html; charset=utf-8">
I'm reading elsewhere the tag might be:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Your php file is not utf-8 but the browser is reading it as utf-8 which is giving you that question mark character. Save your file as utf-8, most editors/ides have options to set the charset of the file.