Problems with UTF-8 in retail LocaWeb [duplicate]

1

I have a project hosted on locaweb in reseller, php / html are correctly encoded in utf-8, since what is html or echo is returning perfectly, but information coming from the bank is not returned correctly with ç, á, é. ..

Via HeidiSQL I have already tried several ALTER TABLE procedures for utf8 and general_ci, but none was successfully completed, via Heidi I can see that there are two types of information from SESSION and GLOBAL variables, SESSION is correct with utf8, but GLOBAL is latin1 and latin1_swedish_ci.

Information is brought via PDO and the database is MySQL.

Summary, not PHP (everything possible has already been tested) and is not the goal of HTML.

Question:

How to modify so that the information comes in utf8 correctly without the hassle of utf8_encode?

Is there any way to exchange mysql information, as we do with php.ini on locaweb?

    
asked by anonymous 26.07.2017 / 19:53

1 answer

0

Try setting PDO to UTF-8 on connection creation:

conn = new PDO(
    'mysql:host='.$host.'; dbname='.$db,
    $user,
    $senha,
    array(
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
    )
);
    
26.07.2017 / 20:03