Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using "ñ" in a JS file

I have this form dropdown thats populated by a JS file. One of the options in my dropdown has the character ñ, but instead of the showing the letter it shows this: �.

How can I get the form to show the letter ñ? (something like an ascii code but for JS?)

thanks in advance...

like image 784
ChrisBedoya Avatar asked Jun 08 '11 19:06

ChrisBedoya


1 Answers

First of all, fixing the encoding of the page (to UTF-8, preferably with <meta http-equiv="content-type" content="text/html; charset=utf-8"/> directly after <head>) and making sure your editor is set to UTF-8 is generally a very good idea.

Otherwise, replacing ñ with \u00f1 (in JavaScript code, not HTML) is the way to go.

If the JavaScript gets the ñ from an HTML or XML document, you can also use &#x00f1; or &ntilde; there.

like image 104
phihag Avatar answered Oct 01 '22 03:10

phihag