Hi guys
I am a bit lost in translation with some unicodes characters I have to manage in my WordPress project. Here is the scene. I am working on a msuci and artists database. My source dataset is a CSV file, where all characters are UTF8 encoded. Here is the name of a finnish artist (Kaarija):
Käärijä
I am the importing this CSV dataset into a Mysql table “artists\_table” (field : performer VARCHAR(255) CHARACTER SET utf8 NOT NULL). Here is how each record is processed:
`foreach ($row_data as $key => $value) {`
`$row_data[$key] = mb_convert_encoding($value, ‘UTF-8’, ‘auto’);`
`}`
`// check the record doesn’t already exists`
`$wpdb->insert(‘artists_table’, $row_data);`
The record is then stored like this, in the database:
https://preview.redd.it/022qdhv31p8d1.png?width=346&format=png&auto=webp&s=3edfe43a56dbd8905514b63efde3f8cbd7a2e5e3
Now comes the tricky part where I am lost. I have a function that creates (automatically) posts for each artist from the database and has to compare post titles with items in the database as part of the business logic. Post title is the one recorded in the DB, see an extract from the posts table:
https://preview.redd.it/bj12j2he2p8d1.png?width=789&format=png&auto=webp&s=575e3ea3c336be68831de41846c5ee78d6cd7e21
Should I work with UTF8\_decode when displaying data to the user, or should I manage it at the source and have the right decoded names in the “artists\_table” (then, how ?)
Many thanke for your feedback !
[ad_2]