Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is ñ changing to ñ?

Tags:

java

unicode

I don't understand whenever I save any string that contains ñ it changes to ñ. Even in the database the ñ is changed to ñ.

Examples:

  • ñ becomes ñ.
  • Niño becomes Niño.

I don't have any clue what causes this problem or where the problem is coming from. Please help. Thanks in advance.

like image 324
NinjaBoy Avatar asked May 29 '12 00:05

NinjaBoy


1 Answers

Character ñ (U+00F1) is encoded using UTF-8 as the two bytes 11000011 10110001 (0xC3 0xB1).

These two bytes are decoded using ISO 8859-1 as the two characters ñ.

So, you are most likely using UTF-8 to encode the character as bytes, and ISO 8859-1 (Latin-1, as guessed by Sajmon) to decode the bytes as characters.

like image 155
Nathan Ryan Avatar answered Sep 22 '22 19:09

Nathan Ryan