Friday, December 01, 2006

Getting UTF-8 Encoding with XMLTextWriter.

One of our web-service we developed has a rather unique parameter: a well-formed XML document passed in a string format. Or, to put it in another way, a string parameter whose output written out in a file will become a well-formed XML document. There a variety of reasons for doing this, instead of say using an XmlDocument type, but that's really not important.

This presents an interesting problem: how DO you create an XML document and convert it into a string, hopefully without writing too much code?

As it turns out: not easy. We started out doing it the hard way: string concatenation. Boy, talk about doing things the hard way. Mal-formed XML, slow performance, etc. Yup, all the potential problems hit us one time or another.

Next, we moved to using StringBuilder. Performs better, but doesn't remove the problems of properly-formed XML.

Then, we improved to using XMLDocument. Finally, we're getting somewhere. But the solution is a little bit overkill, due to the fact we do not need to manipulate the XML document in any way before converting it into string.

Then, I stumbled upon using XMLWriter and StringWriter. Initially, I gave XMLWriter a pass because I mistakenly believed it can only be used to write to a file, and not to memory. Well, with StringWriter, you can. Problem solved!

Well, not quite. It turns out the StringWriter encoding is set to UTF-16, and there's no way to change it. Bummer.

In the end, I found the solution: use XMLTextWriter, MemoryStream and StreamReader. All this just to get the encoding just the way you want it. The solution is less elegant, but it IS less code than the rest of the solution mentioned that doesn't use XMLTextWriter, and it works. Sometimes, you just have to take some compromise. I know I'll be happier with this solution than the others. :)

My Hotmail account is now 1GB

Ah, I still remember not too long ago, my Hotmail account is just a measly 2 MEGABYTES. Well, some time this year, it became a 25MB account, still measly compared to GMail or even Yahoo! Mail, but literally ten time more than I had since I first created this account.

Finally, it is now 1GB. Great! More than enough space to keep my spam from blowing up my account. Wish it doesn't take so long, since Gmail is now pushing past the 2.5GB limit. On the other hand, who really need that much space anyway? Even with the amount of spam and email I'm getting, I'm still using only a small percentage of the total.

However, someone DID find some use for all those space. Enter GMail Spaces, an extension for FireFox. I have not used it yet, but it reminds me of those times where the only one way to bring large files home is by splitting it and sending it to our email by attachment.

Thursday, November 30, 2006

New post: Finally.

A month since my last post, thanks to the troubles of a faulty broadband connection. Actually, the connection was fixed a couple of days after my last post, however it became a major factor in posting procrastination. I will post more on the solution to my broadband problem later.

For now, this post is just to kick-start my blogging habit again. Hopefully, nothing major will stop me from blogging again.

Monday, October 30, 2006

ASP.NET: Adaptive Rendering Model

If you are used to viewing ASP.NET pages on different browsers, you would noticed how some pages looked different on IE as opposed to say Firefox. Or as sometimes it happens, a page would look fine on IE but not on any other browser.

I originally had thought this is basically a screwup on IE being more lenient on some HTML standards, and thus are able to look just fine with the rendered HTML from the ASP.NET pages.

Apparently, that is not entirely true. Certainly not in the way I described at least.

I recently discovered that ASP.NET actually render HTML 4.0-compliant HTML for IE, and HTML 3.2-compliant HTML for other browsers. This is the main reason why there is such a difference between different browsers.

Read more about this from Scott Michell's article on the subject.

BTW, this behaviour is noted for ASP.NET 1.1. I have no clue if the same is true for ASP.NET 2.0

Broadband Blues

Gotta love my broadband connection this past week. Last weekend, I finally managed to get to a website without timing out. Then, I found out that downloading files are lightning fast. Oh great, so my file downloading speed are just fine and dandy, just that getting to the files through the websites are taking forever. -_-

I also decided to call the ISP support to get an update on my connectivity issues. Took a little longer to get through, being the weekend, but after about 10 minutes I got someone. Gave my report ID to the guy and waited for the response.

Then he gave me the bad news: they have escalated this issue to the next level, and they have assigned someone to look at it, but it is still in progress, because of a number of excuses like understaffed and the festive season. So, hopefully someone will continue to look into it on Monday.

I basically intepreted it as this: yeah, we suck at getting the job done, but hey, you're getting free support here, since that's what you paid for, you have to live with it. Technically, they're right, but since I still have to pay them monthly regardless of bad connections, that's not how i think about it. -_-

I really hope the business package get way better support than this, because if they are relying on the Internet for their business, they are going to lose a lot of money from the past few days.

Friday, October 27, 2006

My broadband connection is slower than dialup.

It has been like this since last Sunday. There was a freak thunderstorm that day, where the road leading to my housing area was flooded for a short period. I'm not surprised if it somehow cause the connection slowdown.

Right now, it is almost impossible to surf the net, even the local content. Heck, I can't surf the web page of my ISP, and if I can't go there, I can't go anywhere!

Anyway, I've already made my report to the support centre, though I don't expect them to solve the problem anytime soon. I have this  impression that the call centre support team has a huge communication barrier with the ones handling the hardware connection of the broadband. This was previously vindicated because I once had my account transferred to another line, but the physical line hookup to the switch was not done until two weeks later.

Thank god for office connection...

Wednesday, October 18, 2006

Testing some other features of Live Writer

Trying something out here: the Insert Picture in Live Writer. Wonder how it will look? Especially considering the fact I did not link this picture on any site. If so, why the heck did it let me insert it with no link? Oh wait, when I tried publishing, Live Writer just told me that this blog does not support image uploading, and I should try to upload the image through FTP to somewhere. Not bad! Now I just need to find a proper image hosting site.

One other thing: Live Writer does not support Blogger Beta's labels. Too bad, it is something that Blogger finally has for managing categories of posts. Oh well, it just means that I have to occasionally log in to Blogger and use their editor to add in the labels later. One small compromise in the grand scheme of things. I don't think I can blog consistently with writer.

P.S. I don't know why, but I noticed my spelling just deteriorates while typing on my laptop. I guess it's due to the keyboard sensitivity and spacing. And I have to use this most of the time too. -_- Thank god for spell checker on Live Writer.

Checklist: Stuff to Learn by 2006.

No, that's not a misprint: this is actually my checklist of things to learn by the end of 2006. Why? Two reasons:

1) Vista is launching, and with it the official .NET Framework 3.0 release (and god knows what else).

2) I have a free ASP.NET 2.0 exam ticketthat expires by the end of this year.

This is my list:

1) ASP.NET 2.0

  • Master Pages
  • Site Navigation
  • DataSource
  • Membership, Roles and Profile
  • BOATLOADS of other new features.

2) .NET Framework 3.0

  • WCF
  • WF
  • WPF
  • CardSpace

3) Other stuff

  • ATLAS
  • CSS

Of course, realize that for each bullet point (ESPECIALLY point #2), there TONS of details to go through.

For example, Master Pages by itself are pretty simple, but then you have to consider how to implement it in actual scenarios, like upgrading existing pages to use a Master Page, or multiple Master Pages, etc.

Technically, I have two months to finish ALL that, if I want to keep up. Impossible, some would say. But hey, at least I have an opportunity to learn some of these as part of my current workload, so I might just make it. Sure there's probably no way I can finish them all, but getting a headstart will be better than nothing. And by hook or by crook, I'm gonna use that free exam ticket, darn it! AND pass the exam, of course! 

Monday, October 16, 2006

My Live Writer Impression

OK, just before this post, I just had a HORRID time get Live Writer to connect to Blogger, though I can't say if it's really the Live Writer's fault. Specifically, the Live Writer couldn't detect Blogger blog setting, so I have to look for how to set it manually. Now, this problem was noted in the Live Writer team blog, but I did not expect it to happen again so soon after an update to fix it.

Anyway, on to some more positive impressions on Live Writer.

1. Offline Support: Definitely something I am looking for. One of the problem I faced with blogging is whenever I feel like blogging, my access to the Internet is slow, or none at all. Now that I can save my draft offline, and publish it whenever I want, this means I have much less excuse for not blogging.

2. Insert code: This is available as a plugin from the Live Gallery, but it is incredibly important me. It's not perfect, and I have to tweak the HTML code to suit my needs, but it's still way better than no syntax highlighting, and any of my previous attempts on manual editing.

[ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
[ServiceKnownType(typeof(PurchaseOrder))]
public interface IOrderProcessor {
[OperationContract(IsOneWay = true, Action = "*")]
void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> msg);
}

Overall, the Live Writer is living up to my expectation (even though Blogger is begining to disappoint me in its features). Hope to see more improvement on it as time goes by.


EDIT: OOPS, accidentally deleted this post while trying to fix the syntax highlighting (all the other updates are done on Blogger editor). Good thing I have a copy left on my Live Writer. However, my syntax highlighting is still messed up. Ugh, I guess I'll have to check it later... or give up trying to post code. -_-

Thursday, October 12, 2006

Watching the MIX06 Keynote

One of the first thing I get from the MIX06 website, and about halfway through the keynote. Normally, I don't blog anything about the videos I saw - in fact, the first 39 minutes is quite boring - but on the minute 39:30, they brought the BBC Director of New Media & Technology, Mr. Ashley Highfield, for a demo. THAT is what got me posting this.

In brief, he shows the BBC Gadget in Vista, which launches into a fullscreen WPF program, which is INCREDIBLE. This is one program that you have to see it to believe it, so get the keynote if you can. Do note it is a large video download, so spare some bandwidth.

I have been impressed with WCF, WF, and Cardspace, and this is where I focus my interest in. In this demo, I can see signs of all this in use, or potentially be used, but the experience is only so profound because the way it was presented using WPF. I have largely been taking WPF for granted, mainly because it does not (seemingly) involve with anything I doing now. After that demo, I'm no longer so sure. It gave me something to ponder about...

Well, I'm now way over lunchtime, and already I've spent more than half an hour composing this. I better continue this later.

P.S. So far I love this Live Writer. While it seems no better than your average editor, I prefer this than using the web-based editor of Blogger.

MIX '06 Sessions

I just stumbled upon MIX 06's website, which is a Microsoft event held some time in March. The best thing about it is the Session Videos, which has a chockfull of videos to download. There's more stuff in there, though the videos alone is worth it.

P.S.: Using this post to try out the "Insert Tags" feature in Live Writer.

del.icio.us tags:

Tuesday, October 10, 2006

Here we go again...

Some time early this year, my Blogger account just lost the link to this blog. I largely suspect this is because of the move to the new Blogger Beta site, but I have no proof. It does however discouraged me from blogging for quite some time.

The fact my PC died a few weeks later doesn't help either. -_-

In the end, rather than spending more time trying to recover access to my blog, I just delete it and start over again. Hopefully, I will be able to get into the groove again.

This first post is also a small experiment with using the Live Writer program. So far, the Live Writer impressed me with its features. Maybe I should post more about the writer once I made a few more posts using it.