javascript - Variable names and character encodings -


i have checked π valid javascript variable name. also, when try writing var π = math.pi in chrome console, fine.

however, when include line var π = math.pi inside .js file written sublime text 2 on mac, chrome complains:

uncaught syntaxerror: unexpected token illegal 

i have tried encodings utf-8, utf-16 le , utf-16 be, none work. when execute line console.log('π'), written inside sublime text 2 utf-8, chrome prints:

Ï€ 

how can use javascript variable name π in sublime text 2, chrome understands it?

check make sure setting <meta charset="utf-8"> in head of html or if charset different can set charset attribute on script tag:

<script src="script.js" charset="utf-8"> 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -