Scott Hanselman

The Importance of being UTF-8

September 29, '06 Comments [7] Posted in ASP.NET | Internationalization
Sponsored By

Kevin Hammond at http://www.casadehambone.com/ wanted the title of his blog to be "Casa dé Hambone" - note the é. He's running DasBlog and saw "Casa d Hambone" - note the missing é.

I knew/know that this works fine in DasBlog because it's been internationalized since Day 1 - we've got 14 languages out of the box. He sent me his site.config file (that's where DasBlog stores its configuration) and I opened it in Notepad2.

Notice in the screenshot that this file is saved as ANSI/ASCII. This file was probably manually edited with a non-clever editor.

Utf81

However, if you do a straight convert, of course, you'll lose data (and Notepad2 warns you of this fact). Notice what happens when I do a convert via File|Encoding:

Utf82

This is one situation where the Windows Clipboard works great and can save you a hassle. I selected all , copied to the clipboard, changed the encoding, then pasted.

Utf83

Now we're cool. ASP.NET and .NET in general will almost always "do the right thing" if you're using UTF-8. You can certainly specify alternate encodings if you like when you're opening a file via code. We use the StreamReader internally and the docs say:

StreamReader defaults to UTF-8 encoding unless specified otherwise, instead of defaulting to the ANSI code page for the current system. UTF-8 handles Unicode characters correctly and provides consistent results on localized versions of the operating system.

Joel's got a good article I've pointed to before about Internationalization. I've also got some posts in my Internationalization/i18n category.

Changing to UTF-8 fixed Kevin's problem.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Windows Vista, Junctions and moving My Documents to another drive.

September 29, '06 Comments [4] Posted in Musings
Sponsored By

I've blogged about Junctions (Reparse Points or "Hard Links") before, as has Travis with his Junction Shell Extension. Junctions are great for organizing your code because you can start using relative paths again, even when your project structure doesn't lend itself to relative paths. (Sometimes folks even SUBST a drive and "everyone builds to S:" to make this easier. I say ick to that.)

It seemed to me as I spread the word about the wonder and glory of Junctions (as was as the fantastic danger as in Windows XP SP2 when you delete a junction from Explorer, you delete what it points to!)

So, I was thrilled to notice some interesting and very cool new things regarding Junctions on Vista.

Vistajunction2First, in Vista now, deleting a junction point in Explorer doesn't delete the pointed-too folder. If you've used Junctions in Explorer, you'll realize this is huge.

Also, in Vista, while there's no way from Explorer to tell WHERE a junctions points to, either in the Properties or a Tooltip nor in the "Type" column in Details View (insert obvious feature request here) they at least include a Shortcut Icon Overlay on a Junction. It still says "Folder" when you look at it in Details, while a Shortcut to a Folder says "Shortcut." At least that's a start! In this screenshot the first icon is a folder while the second icon is a junction pointing to the first.

This got me thinking, since I keep all my data on a separate drive D: for "DATA." A lot of us do.

In Vista, "Documents and Setting" is now "C:\Users" and a lot of other stuff has changed. They MOVED my cheese. So, where did they move it, and how do they make things point to the newly moved stuff?

They use Junctions, making their first mainstream appearance! I went to C:\Users and did this:

C:\Users\Scott>dir /a /s | find /i "junction"
09/08/2006  01:23 AM    <JUNCTION>     Application Data [C:\Users\Scott\AppData\Roaming]
09/08/2006  01:23 AM    <JUNCTION>     Cookies [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Cookies]
09/08/2006  01:23 AM    <JUNCTION>     Local Settings [C:\Users\Scott\AppData\Local]
09/08/2006  01:23 AM    <JUNCTION>     My Documents [C:\Users\Scott\Documents]
09/08/2006  01:23 AM    <JUNCTION>     NetHood [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Network Shortcuts]
09/08/2006  01:23 AM    <JUNCTION>     PrintHood [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Printer Shortcuts]
09/08/2006  01:23 AM    <JUNCTION>     Recent [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Recent]
09/08/2006  01:23 AM    <JUNCTION>     SendTo [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\SendTo]
09/08/2006  01:23 AM    <JUNCTION>     Start Menu [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Start Menu]
09/08/2006  01:23 AM    <JUNCTION>     Templates [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Templates]
09/08/2006  01:23 AM    <JUNCTION>     Application Data [C:\Users\Scott\AppData\Local]
09/08/2006  01:23 AM    <JUNCTION>     History [C:\Users\Scott\AppData\Local\Microsoft\Windows\History]
09/08/2006  01:23 AM    <JUNCTION>     Temporary Internet Files [C:\Users\Scott\AppData\Local\Microsoft\Windows\Temporary Internet Files]

Notice that I had to use /a because these junctions are HIDDEN as well. But, because they exist, when folks concatenate things after calling "GetSpecialFolder" they'll still get what they need.

I had a little trouble with my upgrade because I ended up with some stuff on my C: and My Documents on my D:, but Vista was still pointing to C:\Users\Scott for My Documents.

I tried to get tricky like this:

C:\Users\Scott>junction "My Documents" "D:\Scott\My Documents"
Junction v1.04 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2005 Mark Russinovich
Systems Internals -
http://www.sysinternals.com
C:\Users\Scott\My Documents: JUNCTION
   Print Name     : C:\Users\Scott\Documents
   Substitute Name: C:\Users\Scott\Documents

But while a cross-drive junction succeeded with Junction.exe, it apparently really didn't:

C:\Users\Scott
>dir *doc* /a
 Volume in drive C is 70 GIGS - SYSTEM
 Volume Serial Number is 88F3-D225
 Directory of C:\Users\Scott
09/08/2006  01:23 AM    <JUNCTION>     My Documents [\??\D:\Scott\My Documents]
               0 File(s)              0 bytes
               1 Dir(s)   6,877,286,400 bytes free

...and...

Vistamydocuments1C:\Users\Scott>dir /a "My Documents"
 Volume in drive C is 70 GIGS - SYSTEM
 Volume Serial Number is 88F3-D225
 Directory of C:\Users\Scott\My Documents
File Not Found

You are supposed to be able to create a "Volume Mount Point" like in *nix where you point a directory at a volume, but that's not exactly what I need here. I'm not sure why it didn't work, because it's supposed to be supported scenario in NTFS.

Well, while I'm not getting the junction to work, I can still move My Documents in the registry by simply right-clicking on the Document folder and moving it with the built-in UI as we've always been able to in Windows XP. It appears that David Mohundro has discovered some of this interesting stuff as well, although I'm not seeing the same behavior as him; my "Documents and Settings" folders are totally gone and emptied, replaced by C:\Users.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Security in MSXML4 and 80072efd

September 29, '06 Comments [1] Posted in
Sponsored By

Old news, but it matters to some. If you're using MSXML4 and you get this while doing a POST:

msxml4.dll error '80072efd'
A connection with the server could not be established

It might be because of the tightened security around MSXML 4.0 SP2.

The docs say:

"Security in the implementation of the MSXML 4.0 SP2 ServerXmlHttp object has been enhanced to check the Internet Explorer security policy setting for submitting non-encrypted form data. A security policy setting of "Disable" or "Prompt" for the "Submit nonencrypted form data" option will result in an "Access Denied" error message when attempting to post form data using the ServerXmlHttp object. This is a change that can potentially break existing code that uses earlier versions of the ServerXmlHttp object (such as prior released versions of both MSXML 3.0 and MSXML 4.0) to post form data when the Internet Explorer security policy setting for submitting non-encrypted form data is not enabled."

This might happen if you have an existing application running on, say, Windows 2000, then you upgrade the machine to Window 2003 and get the new MSXML "for free." Remember - know the application stack, the whole stack if you can. The OS is part of the stack, and in this case, XML is too.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Hanselminutes Podcast 34 - Scott talks to Chris Sells

September 27, '06 Comments [12] Posted in Podcast
Sponsored By

My thirty-fourth Podcast is up In this unusual episode I head over to Chris Sells' house to chat. It's a little longer than usual, but Chris is an interesting guy. We ramble, but cover software design, user experience, programmer personality types, and Windows Vista. This is the first show I interviewed someone on (not counting the TechEd "on the floor" show) so if it's interesting (or not) let me know and we might do others.

We're listed in the iTunes Podcast Directory, so I encourage you to subscribe with a single click (two in Firefox) with the button below. For those of you on slower connections there are lo-fi and torrent-based versions as well.

Subscribe: Feed-icon-16x16 Subscribe to my Podcast in iTunes

Links from the show are also always on the show site, although this show had no links to speak of. Do also remember the archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

We have new sponsor for this episode, /nsoftware. They've got a great deal in their Red Carpet Subscription package that includes IP*Works!, SSL, S/MIME, S/Shell, Zip, EDI, IBiz Integrators for QuickBooks, E-Payment, Vital/TSYS, Paymentech, USPS, and other solutions. I've personally got a Red Carpet Subscriptions and I encourage you to take a look. 

Check out Aspose, the .NET and Java Component Publisher. They produce a wide variety of components with versions in both .NET and Java. Do check out their Aspose Demo Downloads as they have a huge catalog of tools to explore.

Our sponsors are Apose, /nsoftware, CodeSmith Tools and the .NET Dev Journal.

There's a $100 off CodeSmith coupon for Hanselminutes listeners - it's coupon code HM100. Spread the word, now's the time to buy. This coupon is good for the CodeSmith Professional With 1 Year Premier Support option.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

  • The basic MP3 feed is here, and the iPod friendly one is here. There's a number of other ways you can get it (streaming, straight download, etc) that are all up on the site just below the fold. I use iTunes, myself, to listen to most podcasts, but I also use FeedDemon and it's built in support.
  • Note that for now, because of bandwidth constraints, the feeds always have just the current show. If you want to get an old show (and because many Podcasting Clients aren't smart enough to not download the file more than once) you can always find them at http://www.hanselminutes.com.
  • I have, and will, also include the enclosures to this feed you're reading, so if you're already subscribed to ComputerZen and you're not interested in cluttering your life with another feed, you have the choice to get the 'cast as well.
  • If there's a topic you'd like to hear, perhaps one that is better spoken than presented on a blog, or a great tool you can't live without, contact me and I'll get it in the queue!

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

What's the upper limit on the number of projects within VS2005?

September 26, '06 Comments [13] Posted in ASP.NET
Sponsored By

I had a friend whose team said:

"...most of them have 1GB of RAM and Pentium 4 3.0Ghz HT CPU’s. hey are all complaining about performance, especially with build times. Visual Studio is eating up most of the memory on their systems. Right now those with 1GB of RAM are generally running around 1.2GB of memory usage, so they are swapping like crazy and thus adding even more overhead. There are a couple systems with 2GB of RAM with Core Duo CPU’s. These systems are having the same issues where they are using 2.2GB of RAM, most of which is meaning eaten up by Visual Studio."

And I asked...

"Do they have too many projects in their solution?"

and he said...

"They said 50 projects and growing."

...and Scott Guthrie posted last week on optimizing build times in VS 2005.

"1.2GB RAM usage is pretty out there...50 large projects will strain a system depending on what they are doing. They should look hard at whether they really need all 50 in one solution.  Multiple solutions (even with multiple instances of VS running) work great too."

Clarifying Update from ScottGu:

You should be able to load 50 projects in a single solution - my comment in the origional mail wasn't to imply that you can't.  It was more than 1.2GB of RAM to-do so is larger than I would expect (unless each project is large and there are lots of cross project references).

Editoral: That makes me suspect Resharper as the issue in this case..

As an aside, they were also running Resharper at the same time, and it's currently unclear how much memory was being used by Resharper's on-the-fly analysis. I'll post if I learn more.

Nutshell: Try to break your projects up into reasonably sized subsystems that can build separately. Our SDK has about six solutions, each with about 10 projects.

If you're running VB and you're hitting the VB-specific problem with large projects, you can get a HotFix here.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.