Jane Dallaway

Jane Dallaway

Jane Dallaway  //  Data loving developer/leader/product shaper, storyline curator/creator, life-long learner, photographer, dog owner, reader, crafter, gardener and occasional snowboarder

This blog contains all sorts of odds and ends, from event reviews, stuff about my storyline project, bits of craft, through thoughts on learning, to photography stuff, and general inspiration things. It's a bit all over the place with no real theme, but then so am I!

Email: jane @ dallaway.com
Also at:    

Localisation, Javascript and extended character sets in Visual Studio 2005

I'm currently doing some work on looking into producing a localised version of a Madgex job board (not dis-similar to the work I did this time last year)and am mainly looking at the SQL Server and javascript areas whilst a colleague looks at the .NET side. Glenn gave me a tip off that when he'd been doing something similar, he'd had problems with Visual Studio 2005 not saving his javascript files as UTF.

So, within VS2005 I created a javascript file and put 2 lines into it. They were simply:
alert ('hello world');
alert('Zarys gramatyki por¢wnawczej jezyk¢w slowianskich');

I then linked this into a (very) basic HTML page

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
  <title>i18n</title>
  <script type="text/javascript" src="js/i18n.js" language="javascript"></script>
</head>
<body>
</body>
</html>

so that on pageload 2 alert boxes are displayed, one saying 'Hello World' and the one saying 'Zarys gramatyki por¢wnawczej jezyk¢w slowianskich'.

Unfortunately what is displayed instead is:

Media_httpfarm4static_enrfh

which isn't exactly what I had in mind.

I opened the file in Notepad++ (my text editor of choice) to take a look at the file type and it is, as I'd expected, saved as ANSI, not UTF-8 or UTF-16

Media_httpfarm4static_ajbcb

I used Notepad++'s menu item Format -> Convert to UTF-8 to convert this file from ANSI into UTF-8, and then re-ran my test and all works correctly as expected. Hurrah!

I then repeated this using VS2008 and found that this is one of the fixes over VS2005.

So, the alert now correctly displays:

Media_httpfarm4static_ljccv

and when opened in Notepad++ the file is now, correctly, UTF-8.
Media_httpfarm4static_ksfwy
Filed under  //  javascript   localisation  

Comments (0)