简体   繁体   中英

Troubles with text encoding on spanish

I have a webpage that has some text on spanish and some words have accents and spanish characters, on the webpage i have a datatable retrieving information, the thing is, when i use the tag:

<meta charset="iso-8859-1">

http://i.imgur.com/sjq53ee.png

it displays correctly the text on the Footer, with accents, but the information from the datatable gets a lot of trash chars.

but then again, if i use the tag:

<meta charset="utf8"> or
<meta charset="latin1_spanish_ci">

http://i.imgur.com/M5eUyHA.png

i get the datatable information correctly, but the text on the footer now gets the trash chars.

Already tried with different encodings and combinatios of them and still not working.

Tables and database are on latin1_spanish_ci collate

我将对带有变音符号的字母使用unicode编码。

please take this solution :

 <!DOCTYPE html>
  <html>
  <head>
  <meta charset="utf-8"><!-- Your HTML file can still use UTF-8-->
  <title>Untitled Document</title>
  </head>
  <body>
  <?php
   /*Just for your server-side code*/
  header('Content-Type: text/html; charset=ISO-8859-1');
  echo "àè";
  ?>
  </body>
  </html>`

I got it from here How to display special characters in PHP

  • What bytes to you have in the source? (Provide hex)
  • What did you use when calling mysqli_set_charset()
  • What is the CHARACTER SET on the column in the table?
  • What <meta ... charset...> did you have.

Please state all for, plus any output.

To show the hex from PHP, use

$hex = unpack('H*', $text);
echo implode('', $hex);

To show the hex in the table, do

SELECT col, HEX(col) FROM tbl WHERE ...

With the answers we can pin down what you did wrong and how to fix it.

Ok, what i did was use the second option, the one where the information from the database was correct, and for the footer information i used escape characters &Oacute;&Ntilde; maybe not the best solution, but after breaking my head all afternoon i think this one is the easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM