0

I updated my MAMP server (masOS) and it updated mysql and PhP and I have now encoding problems I didnt have before.

To try to keep it simple, let's take a first example : when I do a mysqldump of my database, I get a mysql file starting by :

--
-- Host: localhost    Database: cailcail
-- ------------------------------------------------------
-- Server version   5.7.39

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `galeries`
--

DROP TABLE IF EXISTS `galeries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `galeries` (
  `Id_galerie` int(11) NOT NULL AUTO_INCREMENT,
  `Sur_galerie` int(11) DEFAULT '0',
  `Annee` int(4) NOT NULL,
  `Id` varchar(50) COLLATE utf8_bin NOT NULL,
  `Chemin` varchar(100) COLLATE utf8_bin DEFAULT NULL,
  `Titre` varchar(500) COLLATE utf8_bin DEFAULT NULL,
  `Enfant` varchar(15) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`Id_galerie`)
) ENGINE=MyISAM AUTO_INCREMENT=403 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `galeries`
--

/*!40000 ALTER TABLE `galeries` DISABLE KEYS */;
INSERT INTO `galeries` VALUES (1,0,2005,'Noël 2004','Noel2004','Noël 2004',NULL),(6,0,2011,'Finistère Sud','FinistereSud','Février 2011 : Finistè [...]

as you can see there is a problem with the accents. The weird thing is : when I open that *.sql file in my text editor I can't find an encoding that make the accent looks good. The one I put above is utf-8 but I try all the available encoding and none renders the accent properly.

So, before digging more in my php/html problem, I would like to understand in what encoding the text in my database are ... If anybody has any idea or any test to do, dont hesitate :)

thanks and have a nice day

pierremomo
  • 41
  • 4
  • `ë` is Mojibake for `ë`. See https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored for causes and cures. – Rick James Jun 29 '23 at 01:49
  • To solve your problem try: (1)-> Mysql database: Create your database with: utf8mb4_general_ci; (2)-> Mysql tables: CREATE TABLE (...) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; (3)-> Mysql connection: mysqli_set_charset($you_connection, "utf8mb4"); (4)-> PHP header: header('Content-Type: text/html; charset=utf-8'); With this i think you can show right any latin caracters (including french). – Alex Abreu Mulet Jun 29 '23 at 05:36

0 Answers0