How to interpret line break between two MySQL databases

66 views Asked by At

I've an old MySQL database with this column: note encoded as ut8_general_ci, type longtext

I've a new MySQL database with this column: publicNote encoded as ut8_general_ci, type longtext

So, i would like to migrate the data from the old database to the new one. To do this, i've PHP script to request my old database and to do some processing on the data. I've a problem here.

There is an exemple of the old database data

De : XXXX 
Vers : Gare
Vol/Train : TGV Paris
Heure : XXXX


Destination : XXXX

There are two line break between 'Heure' and 'Destination' lines.

And the data migrated to the new database :

De : XXXXX Vers : Gare Vol/Train : TGV Paris Heure : XXXX Destination : XXXX

As you can see, the line break are not added to the new database. I've tried to do nl2br, str_replace, trim but it doesn't work. If we look at the hexa code, i can not seen backspace code, just space (code 20).

bin2hex($row['publicNote'])
4465203a20585858582056657273203a204761726520566f6c2f547261696e203a20544756205061726973204865757265203a20585858582044657374696e6174696f6e203a2058585858

If we look at the json_encode($row['publicNote']):

De : XXXX Vers : Gare Vol\/Train : TGV Paris Heure : XXXX Destination : XXXX

I'm really confused, i do not understand why the line break are not interpreted. It's like if there are not \n to the end of the line on mysql

0

There are 0 answers