Is MySQL mapping type needed to match PHP charset type?

I started debugging my RSS feed because it has some strange characters (i.e. a glyph character) in it. I started with two excellent source resources:

The reason why I think our RSS feed is causing problems is because users copy and paste MS Word documents into a text box on the site, and our PHP pages use the "iso-8859-1" encoding, which is incompatible with special "Windows-1252" encodings for things like markers and smart quotes used by MS Word.

So, I hope to fix this problem, all I need to do is start using "utf-8" on pages that accept / give user input. That is, set the following in the HEAD section:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

The real reason I raise this question is because my DB fields storing my user input are in " latin1_swedish_ci" and I want to know if I need to convert them to " utf8_general_ci"? MySQL really doesn't care about encoding? It just sees a bunch of bytes, and if I put Unicode in a field sorted as Latin, will it still return as Unicode? Changing the field will be tedious because the field is part of the FULLTEXT index, where other fields also need to change their sorting, which means abandoning the index and restoring it (which is important when large TEXT amounts are involved).

+3
source share
4

, , , , , "latin1_swedish_ci", , "utf8_general_ci"?

. latin1_swedish_ci utf8_general_ci - , . , /. , . - - . , utf8, utf8.

mysql charset php. utf8 Mysql, iso-8859-1 php. Mysql, (set names XXX). Mysql . Mysql php, , dommon, , utf8, . utf8 Mysql, php.

+6

- . MySQL , , MySQL , ( = PHP script, , -). ,

SET NAMES 'utf8';

, . MySQL MySQL / . . , -.

, MySQL:

+1

- , , mysql pdo/mysql, :

$dbc = new pdo('mysql:dbname=DBNAME;host=DBHOST', $user, $pw, array(PDO::MYSQL_ATTR_INIT_COMMAND => sprintf( "SET NAMES %s", $charset ) ) );
+1

HTTP charset Content-Type HTTP. HTTP-:

[...] ( ):

  • HTTP "charset" "Content-Type".
  • META "http-equiv" "Content-Type" , "charset".
  • charset, , .

, accept-charset attribute form. ( ) , , :

"UNKNOWN". , , form.

. . , UTF-8 ( /).

0
source

Source: https://habr.com/ru/post/1708167/


All Articles