UTF8 vs Latin1

I am trying to understand the difference between Latin1 and UTF8, and for the most part I get it, however, when testing, I get some strange results and can use some help clarifying

I am testing "é" (latin small letter E with a sharp), and the link below shows hex c3a9

I install the database and the specified utf8 as a character set, and then create a table with utf8 as the character set and inserted the record with the character "é" after establishing the connection and the client character set in UTF8

when I select hex (field), a field from test_table, I get:

hex (field), field C3A9, é

This is fine and consistent with what I read, however, when I do the same using the latin1 character set, I get the following:

hex (field), field C3A9, é

but if I enter char (x'E9 '), which should be the only byte equivalent of Latin1 for é, I can make it display correctly using "set names UTF8", but it does not display correctly if the connection and client settings are on Latin1

Can anyone clarify? - Should Latin1 characters be single byte (Hex E9) in both UTF8 and Latin1? or am I completely misunderstanding all this?

thanks

+4
source share
2 answers

After placing the website through the UTF-8 ringer, I think this is the case of viewing the UTF-8 data in the latin1 table in the encoded page or UTF-8 terminal.

, , ( Ubuntu it Terminal → Set Character Encoding). - PHPMyAdmin, Firebug , "UTF-8".

UTF-8, latin1, UTF-8, .

, , , : UTF-8, UTF-8, UTF-8. , .

+2

latin1 1- .

128 (7 ) latin1 utf8.

é 128; 1-, 8- hex E9 ( ). utf8 2 : C3A9. utf8 3 ; latin1 .

MySQL SET NAMES utf8. , - utf8, , CHARACTER SET utf8 /.

SET NAMES latin1 ( ), utf8, "", . , - .

utf8:

  • utf8
  • SET NAMES utf8 ( MySQL)
  • CHARACTER SET utf8
  • <meta ... UTF-8> html
+1

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


All Articles