0

I everybody, i have a decision to make about making a web site in spanish, and the database has a lot of accents and special characters like for example ñ, when i show the data into the view it appears like "Informática, Producción, Organización, Diseñador Web, Métodos" etc. So by the way, i am using JSP & Servlets, MySQL, phpMyAdmin under Fedora 20 and right know i have added this to the html file:

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

and in the apache, i change the default charset:

#AddDefaultCharset UTF-8
AddDefaultCharset ISO-8859-1

but in the browser, the data continue appearing like this: "Informática, Producción, Analista de Organización y Métodos", so i don't know what to do, and i have searching all day long if doing the websites using UTF-8 but i don't want to convert all accents and special characters all the time, any advice guys?

Mario
  • 51
  • 8
  • How are you storing the data in your database? What encoding/collation are you using in your tables? – Dai Apr 24 '14 at 05:19
  • SCHEMA NAME:inventario DEFAULT_CHARACTER_SET_NAME:latin1 DEFAULT_COLLATION_NAME: latin1_swedish_ci – Mario Apr 24 '14 at 05:27
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – deceze Apr 24 '14 at 07:48
  • [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/), [What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text](http://kunststube.net/encoding/) – deceze Apr 24 '14 at 07:49

2 Answers2

1

The encoding errors appearing in your text (e.g, á instead of á) indicate that your application is trying to output UTF-8 text, but your pages are incorrectly specifying the text encoding as ISO-8859-1.

Specify the UTF-8 encoding in your Content-Type headers. Do not use ISO-8859-1.

  • i already tried that either UTF-8 or ISO-8859-1, because the data at the beginning was in another computer, so i exported using UTF-8 and tried, but display the wrong data, the second time i exported as the ISO-8859-1 and the same issue, that's what i don't understand about MySQL, cause i have already configure the charset in the browser and the apache, and of course i restart the apache after the changes, so i don't know what else to do! – Mario Apr 24 '14 at 05:55
  • i find the solution, when i create the database i didn't choose the "cotejamiento" so MySQL has in my case the "latin1_swedish_ci" by default, and i recently watch that the best option to store this kind of data with accents and special characters is "utf8_spanish_ci", thanks a lot by the way! =D – Mario Apr 24 '14 at 12:08
0

It depends on the editor that has been done anywhere, whether at work by default in UTF-8 or ISO-8859-1. If the original file was written in ISO-8859-1 and edit it in UTF-8, see the special characters encoded wrong. If we keep that which file such, we are corrupting the original encoding (bad is saved with UTF-8).

Depending on the configuration of Apache.

It depends on whether there is a hidden file. Htaccess in the root directory that serves our website (httpdocs, public_html or similar)

Depends if specified in the META tags of the resulting HTML.

Depends if specified in the header of a PHP file.

Charset chosen depends on the database (if you use a database to display content with a CMS such as Joomla, Drupal, phpNuke, or your own application that is dynamic).

josedlujan
  • 5,357
  • 2
  • 27
  • 49
  • ok, but i told that i already that i changed the apache default charset and the meta charset to "ISO-8859-1" in every html file, but i don't understand what else i have to do to display the data correctly, that's my point, what is left to do right now? – Mario Apr 24 '14 at 05:51
  • Your IDE or editor save files as ISO-8859-1 ? Are you sure? check it. Your Database is iso-8859-1 ? – josedlujan Apr 24 '14 at 06:07
  • i am using sublime text to work with the html5, and in java i am working with eclipse kepler (Java EE Platform), and about mysql tha database that i am using its configure as follows: SCHEMA NAME:inventario DEFAULT_CHARACTER_SET_NAME:latin1 DEFAULT_COLLATION_NAME: latin1_swedish_ci – Mario Apr 24 '14 at 06:11
  • Use sublime is not a guarantee, check that long way: New file -> Save file -> Reopen with encoding -> Work – josedlujan Apr 24 '14 at 06:15