0

I am not familiar with the concept of encoding. That's likely my main problem.

However, I just want to be able to take values that are already in my database (SQL Server) and display them in the browser. Some of those characters are from the German alphabet like ä, ö, ü. They display as �� instead.

I've tried lots of variations of php conversion hoping one of them would properly convert the value to the equivalent HTML entity so that it would then display properly in the browser. I know I can replace my text value with the HTML entity and then of course is displays correctly.

Here are some attempts:

$Text = "ü"

// echo mb_convert_encoding($Text,"SJIS");
// echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $Text);
// echo htmlentities($Text, ENT_COMPAT, 'UTF-8');
// echo htmlentities($Text, ENT_NOQUOTES); 

I know there are many other questions that seem related but none that have worked so far. Any help would be much appreciated.

CShore
  • 65
  • 8

1 Answers1

0

Do I understand it correctly that ONLY the database entries are wrong???

Checkif the üäö do work on the page if you insert them with echo"" and /or with html . if these work - then there is a different problem.

The database table & database probably have the wrong encoding and

My suspicion:

The connection to the database can be the problem. Check if this is configured as "utf-8".

The latter depends on your database e.g. für mysql i have the following code directly after the mysql_connect

mysqli_set_charset($link, "utf8");

https://www.php.net/manual/de/mysqli.set-charset.php

  • What's the best way to build a web app supporting non English characters (ü,ä,ö) using PHP and SQL Server – CShore Jan 16 '21 at 00:27
  • The answer is the same. Just set encoding to utf-8 and you can use üäöß in your texts. Please mark answer as accepted if it helped you. – Alexander Dobernig Jan 16 '21 at 07:05