0

I had a working code and moved it to a new server, from php5 to php7. Googling for a week did not help me, so i'm asking you guys.

I have some info with a euro-sign in a sql database: €99.00 The info is stored as utf16-general-ci.

If the info is selected and put in a string, i echo it with: echo $row["Total"];

On the old server it showed: €99.00 On the new server it shows: €99.00

I want to show the euro-sign instead of the character code.

I tried changing to utf-8, but this does nothing. Also htmlentities() or htmlspecialchars() does not do anything.

tshimkus
  • 1,173
  • 2
  • 17
  • 24
  • And when you don't expect, you find the answer. https://stackoverflow.com/questions/35234129/how-to-convert-windows-1252-characters-to-values-in-php – Theun de Vries Mar 31 '19 at 20:43
  • That's great that you found the answer to your formatting answer, but can I ask why you are storing a total as a string instead of a numeric format like a FLOAT or DECIMAL? This format would problematic if you ever wanted to run a query that treats the column like a number. – tshimkus Mar 31 '19 at 23:33

1 Answers1

0

As found in the link How to convert Windows-1252 characters to values in php?

The problem is the Windows-1252 vs ISO-8859-1.

To fix the problem, i used:

mb_convert_encoding($row["Total"], "Windows-1252", "UTF-8")

More info can be found here: https://www.i18nqa.com/debug/bug-iso8859-1-vs-windows-1252.html

tshimkus
  • 1,173
  • 2
  • 17
  • 24