views:

89

answers:

1

I wanna constrain to input special signs like £ ¬ ¦ in javascript,but they are always displayed in ��� on Page source. How can i let them display correctly and page can be validated ? my page is using utf-8

thanks

+3  A: 

Make sure that:

  • You really are using UTF-8 for the page
  • You are using UTF-8 for the JS
  • Your HTTP headers say you are using UTF-8
  • Any <meta> tags you have which mention an encoding say UTF-8

If you can't confirm all of those, you can use: "\u00A3"

David Dorward
i have already using <meta http-equiv="content-type" content="text/html; charset=utf-8" />but how can i know i am using UTF-8 for the JS
Jason
You seem to be confusing step 1 and step 4. For steps 1 and 2, assuming that nothing munges the data on the way, look at the configuration of your editor.
David Dorward
sorry i don't understand. It seems that i just put UTF-8 on the HTTP headers. I should confirm "You really are using UTF-8 for the page# You are using UTF-8 for the JS". javascript codes are outside the form
Jason
i put like these <script type="text/javascript" src="[path]/myscript.js" charset="utf-8"></script>, but it still doesn't work
Jason
Read http://www.w3.org/International/O-HTTP-charset
David Dorward
@Jason: look at the current text encoding to see what your browser is using. In Firefox, you can look at [menu bar] View > Character Encoding and see in the sub-menu which one is selected.
Marcel Korpel