1

Getting the symbol from the above and I'm at a loss what I'm missing. What I've done so far.

Set on header

<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Database output charset: UTF8

$char = mysqli_character_set_name($conn);
echo "The current character set is: $char\n"; 

Set on file.

mysqli_set_charset($conn, "utf8");

File is: UTF 8 Database Table is: utf8_general_ci

EDIT: SHOW TABLE

CREATE TABLE `testimonials` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`showflag` varchar(10) NOT NULL DEFAULT '10',
`heading` varchar(155) DEFAULT NULL,
`testimonial` longtext NOT NULL,
`name` varchar(50) NOT NULL,
`domain` varchar(50) DEFAULT NULL,
`date` date NOT NULL,
`image` varchar(255) DEFAULT NULL,
`rating` int(1) DEFAULT '5',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8

EDIT: Database storage is fine, the issue occurs on output only.

  • Is it stored as that in the DB or on outputting it comes out as that? Please show which `meta` you are now using. – chris85 Jun 09 '17 at 04:02
  • @chris85 Issue only on output. Removed the 2nd meta and only using. –  Jun 09 '17 at 04:05

2 Answers2

2

You seem to have a contradiction with the two meta clauses -- use the same charset.

Look for "black diamond" in http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored

Let's see SHOW CREATE TABLE; the column is the important part.

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • Table and columns are set to utf8_general_ci, Also updated post above for `SHOW CREATE TABLE` –  Jun 09 '17 at 03:50
  • Also weird thing is, outputting via ajax on the backend of the site is fine. but outputting it in the front of the site shows the black "?" could it be possible it's a wordpress issue or plugin? –  Jun 09 '17 at 04:07
  • Check the final generated output by viewing source in the browser. Any other meta tags overriding your charset? – Chris Lam Jun 09 '17 at 04:13
  • @ChrisLam source shows. ��� no other meta. Also I've update post above for the actual page. –  Jun 09 '17 at 04:17
  • Hex is (C390C39EC38620) . symbols are ÐÞÆ –  Jun 09 '17 at 04:20
  • What were you expecting? Any of these:? cp932, sjis 9 3 'テ静榲' euckr 9 3 '횖횧횈' gbk 9 3 '脨脼脝' ? – Rick James Jun 09 '17 at 05:17
  • Or did you really want ÐÞÆ? – Rick James Jun 09 '17 at 05:18
  • Was that the hex from `SELECT HEX(col) ...` ? Or inside the app? – Rick James Jun 09 '17 at 05:18
  • expecting these ÐÞÆ –  Jun 09 '17 at 05:18
  • Check the encoding being used in the browser. Chrome? FF? Other? – Rick James Jun 09 '17 at 05:20
  • `C390C39EC386` is the correct utf8 (or utf8mb4) encoding for `ÐÞÆ`. – Rick James Jun 09 '17 at 05:21
  • So, I am pretty sure the browser is screwing it up. – Rick James Jun 09 '17 at 05:21
  • @RickJames Hi Rick, checked chrom using `document.characterSet` returned UTF-8. I've isolated my code here and restarting everything you set on your guide https://www.webvisions.com/test.php –  Jun 09 '17 at 05:30
  • @RickJames Resolved the issue, the cause was I wrote `mysqli_set_charset($conn, "utf8");` in a function and I neglected to check if it was being carried over to another function. Reviewing your guide help me. Thanks. –  Jun 09 '17 at 05:44
  • Glad you figured it out. `mysqli_set_charset` does not need to be called but once at the beginning of a connection. I hope you are not unnecessarily reconnecting. – Rick James Jun 09 '17 at 14:31
  • @RickJames I was doing something like. `func utf8(){ declare } utf8(); func fetch(){} and I included that php file. I moved the utf8(); call inside the fetch function and it worked. –  Jun 12 '17 at 03:41
2
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

You are setting charset to iso-8859-1..Try changing it to utf-8

Your second meta tag is only useful only for HTML4 though. For modern browsers that work well with HTML5, having only <meta charset="UTF-8" /> is good enough.

Chris Lam
  • 3,526
  • 13
  • 10