0

I am storying names in my database from foreign countries which mean a few of the characters are not easily stored in my db for some reason:

enter image description here

Example name that is not stored correctly:

Moretó Font

It is a postgres DB with a graphQL layer on to to get the data out.

DB Info:

psqlDB| TF8 | en_GB.UTF-8 | en_GB.UTF-8 | 

I have <meta charSet="utf-8"/> in the page

I'm using:

  • postgres v12
  • node.js v14.15.4
  • nextjs v10
  • graphql v15.4
  • postgraphile: v4.5.5

postgraphile generates my schemas and resolves for me so a typical write to my DB looks like within my nextjs application (javascript):

mutation createArtist(
  $firstname: String!
  $surname: String!
) {
  createArtist(
    input: {
      artist: {
        firstname: $firstname
        surname: $surname
      }
    }
  ) {
    clientMutationId
  }
}

create({ variables: { firstname: 'jamie', surname: 'hutber'} })

I wonder if I need to remove all these chars while storing them in the DB?

Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
  • What's the character encoding of the database? –  Jan 15 '21 at 09:27
  • I believe its `en_GB.UTF-8`? – Jamie Hutber Jan 15 '21 at 09:27
  • These question marks mean that an ANSI document is displayed as if it's UTF-8. It's not enough to have that `` line, you need to make sure that your actual HTML documents / templates are actually UTF-8. Open any of them in your IDE and check the status bar at the bottom. It should show the format. –  Jan 15 '21 at 09:34
  • couldn't the camel cased `charSet` be the problem (if it's not coming from a React component I mean) – t3__rry Jan 15 '21 at 09:34
  • @t3__rry when the page is rendered as html that will be output correctly: `` – Jamie Hutber Jan 15 '21 at 11:00
  • @ChrisG the only thing is, my files are all written in js and then compiles into one js file that is output directly on the page. Here is the live url: https://miniatureawards.com/ – Jamie Hutber Jan 15 '21 at 11:01
  • Yes, I use React myself. Check the index.html in your public folder. Check every src file for its character encoding. Again, you have special characters encoded in ANSI and displaying them as if they are UTF-8. This is a very common and very old issue, and would typically occur when people wrote their websites on a windows machine (which stored the files as windows-1252 / ISO-8859-1) but hosted them on a Linux server. See: https://stackoverflow.com/questions/5445137/utf-8-encoded-html-pages-show-questions-marks-instead-of-characters –  Jan 15 '21 at 11:07
  • I'll have a look through now, I've exclusively written this site in linux though. So I would be surprised if any of the files could be. Ye also I just realised I have utf-8 in my `.editorconfig` – Jamie Hutber Jan 15 '21 at 11:17
  • I just saw, the place I am pulling the data from in the HTML it has: `text/html; charset=iso-8859-11` I imagine this could the issue? – Jamie Hutber Jan 15 '21 at 20:27

0 Answers0