I am trying to get some data(varchar) from my database and show them in my html in the right encoding because it contains german special characters. The database is in latin1_german2_ci(cp1252), my html
<input type="text" id="owner" name="owner" value="<?=get_owner() ?>" class="form-control">
function get_owner()
{
$owner = htmlentities($text_I_got_from_db, ENT_COMPAT, 'cp1252');
return $owner;
}
This gives me, ie. Kälte
in my <input>
, but I want Kälte
. I know that htmlentities()
turns special chars to htmlcode. How do I do that it stay that way in html and not "converted back"?
if you want to print text in page 'as is' you may use code like this
$owner = htmlentities('Kälte', ENT_COMPAT, 'UTF-8');
echo htmlspecialchars($owner);