Wednesday, May 30, 2007

The first track from the New Pornographers new album, Challengers, is now streaming on the band's MySpace page. There's also a downloadable copy available on the Matador website at the moment as well.

It's a different sound in some ways to the previous New Pornos albums, but every bit as good! Sounds like Neko in the background, too...

Shame I won't be able to make either of their shows in London, but they've sold out by now anyway. Wish they'd do a proper tour (and, just to make life easy for me, play Reading while they're at it!)

There's also a video for Sing Me Spanish Techno from their last release, Twin Cinema available on iFilm.

Wednesday, May 30, 2007 7:21:59 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
 Tuesday, May 29, 2007

"Everything Sounds Like Coldplay Now" by Mitch Benn and the Distractions.

My favourite lines start around 2:16: "This could be Embrace, Keane or Snow Patrol/Thirteen Senses sound like this as well I'm told/It could be anyone/It's so hard to say/Maybe this is actually Coldplay".

Mind you, Coldplay themselves were ok when I saw them in 2001 at Brixton Academy, and I'm going to see Snow Patrol in June at the O2 Arena, so maybe I shouldn't mock...

Funny | Music
Tuesday, May 29, 2007 10:23:29 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, May 25, 2007

Found via Pharyngula. It would appear that PZ is more militant but less angy than me...

You scored as Scientific Atheist, These guys rule. I'm not one of them myself, although I play one online. They know the rules of debate, the Laws of Thermodynamics, and can explain evolution in fifty words or less. More concerned with how things ARE than how they should be, these are the people who will bring us into the future.

Scientific Atheist

100%

Angry Atheist

58%

Spiritual Atheist

50%

Militant Atheist

50%

Apathetic Atheist

42%

Agnostic

33%

Theist

17%

What kind of atheist are you?
created with QuizFarm.com
Friday, May 25, 2007 8:38:47 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, May 22, 2007

What's wrong with this address: 28 St. Someone’s Close?

The single quote, that's what. It's not a single quote, which is ANSI 0x27, it's actually an ANSI 0x92. This is causing me problems. The address is supplied in a text box on a web page, processed in a StringBuilder to make an XML fragment, and passed via ADO.Net to a SQL Server stored procedure, which is attempting to use sp_xml_preparedocument to read it. However, we're getting an error thrown out of the stored proc:

The XML parse error 0xc00ce508 occurred on line number 1, near the XML text "

Now, working out the problem isn't exactly difficult: we're passing the value in as a text field, so it's (in the words of SQL's books on-line), "Variable-length non-Unicode data in the code page of the server". A change to a unicode field and we should be fine. I probably should make the observation here that there's a note in books on-line to the effect that they're planning to deprecate the text and ntext data types:

Note: ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.

So, I copied the relevant code into SQL Management Studio's query window to have a play, and changed the data type to nvarchar(max), and the sp_xml_preparedocument executed correctly:

DECLARE @hDoc INTEGER, @RailSegmentRemarks nvarchar(max)
SELECT @RailSegmentRemarks = '<RailSegmentRemarks><Remark RemarkID="1" RemarkText="28 St. Someone’s Close, Sometown, Oxfordshire, " /><Remark RemarkID="2" RemarkText="OX12 3AB" /><Remark RemarkID="3" RemarkText="" /><Remark RemarkID="4" RemarkText="" /></RailSegmentRemarks>'

EXEC sp_xml_preparedocument @hDoc OUTPUT, @RailSegmentRemarks

DECLARE @Remarks TABLE (RemarkID VARCHAR(50), RemarkText VARCHAR(50))

INSERT INTO @Remarks
SELECT RemarkID, RemarkText
FROM OPENXML(@hDoc, N'RailSegmentRemarks/Remark')
WITH (RemarkID INTEGER '@RemarkID', RemarkText VARCHAR(50) '@RemarkText') AS XML
WHERE COALESCE(RemarkText, '') <> ''

SELECT * FROM @Remarks

EXEC sp_xml_removedocument @hDoc

Now, the odd thing here is that all the code works: I get a set of fields returned from the final SELECT statement which contain the single quote character. This seems odd to me because while I've declared the @RailSegmentRemarks variable as an nvarchar, I haven't yet changed the rest of the code, which is still just varchar. But everything seems to work. Very strange.

Anyway, all that's left (ha!) for me to do is to change all the relevant variables, table defs, stored procs, views, and everything else that may be affected, to nvarchar. or I could just prevent these characters from being entered in the first place, I suppose...

There are some articles by Michael Rys here and here, which discuss some of these issues.


Update: Everything works ok if I pass in the XML data prefixed with an XML declaration specifying the encoding. This is, obviously, a lot less work than changing everything to handle unicode properly, and is sufficient for our system:

<?xml version=""1.0"" encoding=""windows-1252""?>

I needed an encoding that would match against the Latin1_General-CI-AS that our database uses, and the Windows-1252 (Western Europe Latin character set) does this.

Coding | Work
Tuesday, May 22, 2007 1:30:22 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, May 18, 2007

I'm sure many VB.net coders are aware of this, but since I'm mainly a C# sort of person, I wasn't: the VB.net equivalent of C#'s ternary operator, IIf, does not work in the same way. IIf looks like this:

Public Function IIf( _
    ByVal Expression As Boolean, _
    ByVal TruePart As Object, _
    ByVal FalsePart As Object _
) As Object

Since IIf is a function, every time it is called it evaluates both the TruePart and the FalsePart, regardless of the state of Expression. This is different to C#, which uses the ternary (or conditional) operator:

condition ? first_expression : second_expression;

As stated in the C# langauge reference, "If condition is true, first expression is evaluated and becomes the result; if false, the second expression is evaluated and becomes the result. Only one of two expressions is ever evaluated."

So, in VB.net if you have a situation like the one shown below (which we did!), you've got a problem:

Here, the second expression calls a function TextFormat(String, AlignmentEnum). In the case where the row.Item value is DBNull, when the FalsePart argument is evaluated there is an attempt to cast DBNull.Value to a String, and an exception is thrown. I had to replace the code with an explict If...Else block:

Dim cellText As String
If (row.Item(fieldName) Is DBNull.Value) Then
    cellText = ""
Else
    cellText = PDFCreator.TextAlign(row.Item(fieldName))
End If
objRow.Cells(cellIndex).AddText(cellText, objparam)
Coding | Work
Friday, May 18, 2007 9:44:34 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

I loved this, from the Norwegian TV show Øystein og jeg:

Hat tip: Cosmic Variance

Friday, May 18, 2007 9:19:30 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, May 16, 2007

IE and Excel are rubbish. Just thought I'd get that out of the way first.

Right, we've got a process that sends files, either as attachments to emails or directly over FTP/HTTP. The source of these files is a database, so to send the files we have to write them to disk first. Slighly wasteful at first glance, but it works. The XML files are set as encoded in UTF-8:

<?xml version="1.0" encoding="UTF-8" ?>

Now, it was noticed that the files we created didn't open correctly in IE, with the error "An invalid character was found in text content". I had a quick look, and the character in question was the not-exactly-exceptional "£". It seemed that the reason for the problem was that the file was saved as ANSI (rather than UTF-8), because the code that did the saving used the machine's default encoding:

Dim sw As New System.IO.StreamWriter(mFileName, False, System.Text.Encoding.Default)
With sw
    .Write(mAttachmentContents)
    .Flush()
    .Close()
    .Dispose()
End With

Now, while Firefox (for example), plays nice in this situation and displays the file correctly, IE can't cope with the fact that the file has been saved as ANSI, is declared as UTF-8, and contains a pound sign. So, solution: set the encoding to UTF-8. Simple.

Well, not quite. The same code is also used to create CSV files as well as XML files. I've no idea where or how these files are used (they're just dipatched into the ether as far as I'm concerned), but if they can't be opened in Excel then we regard them as broken. However, Microsoft (in their infinite wisdom), haven't bothered to let Excel cope with CSV files that are encoded as anything other than ANSI, so a UTF-8 encoded CSV file translates the pound sign to "£", which is somewhat annoying. So instead, I have to work out the file type, and encode as UTF-8 or ANSI as required.

As I said, IE and Excel are rubbish.

Coding | Work
Wednesday, May 16, 2007 11:50:41 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, May 03, 2007

Howefest 2: The Return of Howefest

Well, that was another great evening!

We started with a bunch of songs from the current line-up of Giant Sand, who were joined by a visibly nervous Lonna Kelley for 2 numbers. The next guest was Henriette Sennavldt (from Under Byen) who sang 2 songs, the first introduced as an opera, the second being Classico from Is All Over.. The Map.

Next up was Emiliana Torrini, who did a couple of lovely songs with her band (must look out for an album!), then Fernando Vacas and Flow, who were followed by a brief interval.

The second half of the show was started by Mary Margaret O'Hara and band, who did 3 songs. Can't decide here: the musicians were great, and she can clearly sing, but she seemed a little... distracted, maybe? Slightly drunk? Not sure. Next was Isobel Campbell who did a couple of great songs.

Then we had The Handsome Family, who did great versions of Bottomless Hole, After We Shot The Grizzly... and Weightless Again.

Finally, we had the full 'Sno Angel experience, with the Voices of Praise choir. Not sure how many numbers they did, but it included Paradise Here Abouts, Worried Spirits, Robes of Bible Black, But I Did Not, Chore of Enchantment, Get To Leave, and a couple of presumably new numbers that I didn't recognise. Thrown in for good measure was a great cover of Led Zep's Immigrant Song!

Shame it all had to end!

See also:FT review, and here.

Thursday, May 03, 2007 7:49:13 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, May 02, 2007

Apparently, there's a certain number that isn't very popular, at least with the MPAA. So unpopular, in fact, that they want to ban it.

In case you're interested, the number starts (in hex) 09 f9, then has a bunch of other digits, and ends 88 c0.

If you're a decimal person, parts of the middle look like this: 17 2 157 116 227 91 216 65 86 197 99 86.

Just for the sake of it, here's a string of 0s and 1s: 1001111110011000110100111011110100111000111011011110110001000001101011011000101110001110101101000100011000000.

Doesn't seem so scary when it's just 1s and 0s, does it..?

Wednesday, May 02, 2007 11:33:50 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

Thanks to the Giant Sand website, I've found a link to the programme for this evening's fun at the Barbican. The PDF can be found here. God, this is going to be a good show..!

The full line-up is:

Howe Gelb vocals/guitar/piano

Giant Sand:
Henriette Sennevaldt vocals
Peter Dombernowsky drums/percussion
Anders Pedersen guitar
Thøger Lund bass

Isobel Campbell vocals/piano
David McGowan bass
Jim McCulloch guitar

Emiliana Torrini vocals

Lonna Kelley vocals

Mary Margaret O’Hara vocals + band:
Rusty McCarthy guitar
Great Bob Scott drums

Fernando Vacas + band ‘Flow’:
Rocio Barrio
Luis Cortes

The Handsome Family:
Brett Sparks guitar/vocals
Rennie Sparks guitar/vocals
Stephen Dorocke pedal steel

Sno Angel:
Howe Gelb vocals/guitar/piano
Fred Guignion slide guitar
Andrew McCormack drums

Voices of Praise Gospel Choir:
Steve Johnston director
Patrick Joseph
Neema Mugala
Christine Methengye
Jerusha Lewis
Michael Shaw
Wednesday, May 02, 2007 9:38:41 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, May 01, 2007

Tomorrow evening we're going to see Howe Gelb & Friends at the Barbican. It should be an excellent show, with a line-up including "Isobel Campbell, Emiliana Torrini, Mary Margaret O'Hara, The Handsome Family, Giant Sand, Sno' Angel Choir, Lonna Kelly and more special guests, kith and kin and past collaborators to be announced."

I saw the last show of this sort that Howe did, the (Upside) Down Home show that was part of the Beyond Nashville season at the Barbican in 2001, and it was a superb night (voted gig of the year in 2001 by Time Out, and reviewed here by The Independent), and caused me to start listening to Lambchop and Sparklehorse, who I'd not heard before that evening (and who I've seen since on their own).

It's great that the Handsome Family are playing - it was looking like I might have the first year in a few where they didn't play somewhere near me. Wonder who the unnamed guests are - last time PJ Harvey turned up, maybe this year we could have Neko or M. Ward? Hopes....

Tuesday, May 01, 2007 10:22:42 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |