0

I am having problems with accentuation in a project that I am giving maintenance.

Table MYQL using utf8_unicode_ci

String Error

$text = 'São Jos�'; #correct São José
echo utf8_decode($text); #print São Jos�
echo utf8_encode($text); #print São Jos�

How to solve using php 5.6?

Samir Selia
  • 7,007
  • 2
  • 11
  • 30
WMomesso
  • 244
  • 1
  • 4
  • 15
  • let me know the original string language. – VinothRaja Dec 03 '18 at 13:15
  • is pt-BR (Brazilian) – WMomesso Dec 03 '18 at 13:24
  • Hex `EFBFBD` represents the "Replacement Character". In certain situations, it shows as `�`. So, I suspect you mangled the data in an attempt to fix it, and now there are _two_ errors to undo. You will probably have to start over and establish the use of utf8 (or utf8mb4) and several points in your code. – Rick James Dec 03 '18 at 23:45

1 Answers1

1

Before you fetch result from the database, fire below query,

SET NAMES UTF8;

This will set the character-set and the results returned will be proper.

Samir Selia
  • 7,007
  • 2
  • 11
  • 30