Lifestyle, hobbies, work, rage…
C#
‘Nuff said.
Unicode to DOS Filenames
Jan 26th
DOS is a pain. .NET doesn’t get along too well with DOS either, since everything .NET is Unicode – just like everything, actually.
How to change from Unicode (aka, Kanji characters) to DOS Filenames:
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern uint GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string lpszLongPath, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszShortPath, uint cchBuffer);
public static string ToDOSPathName(String longName) {
StringBuilder shortNameBuffer = new StringBuilder(256);
uint bufferSize = (uint)shortNameBuffer.Capacity;
uint result = GetShortPathName(longName, shortNameBuffer, bufferSize);
return shortNameBuffer.ToString();
}
Genpuid troubles
Jan 2nd
Since there is no managed or open source way to get a PUID for MusicBrainz (Thank you, thank you MusicIP…), you have to call it as an external process. However, since Windows makes all the console-based executables have a character set of SBCSCodePageEncoding, accents get messed up.
After several hours of smashing my head against the wall and venting on GTalk w/ scottp, I finally got it to work:
Encoding.UTF8.GetString(ProcessObj.StandardOutput.CurrentEncoding.GetBytes(“yadda yadda”));
And now it all works. Yay! iBrainz is almost finished…
How to check if a path is a Folder
Nov 18th
For the life of me, I couldn’t do anything like this last night. Sleep depravation is deadly.
In case anyone’s wondering, this does the trick:
private bool isFolder(String path) {
return ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory);
}
Yeah. It’s nice.
Working with MusicBrainz
Nov 15th
I decided that while I’m on winter break, instead of doing something useful like.. I don’t know, finally getting some rest, I’ll code yet another MusicBrainz client. Yes, yet another project. Picard sucks and the MBTagger is being discontinued quite soon, so…
I stumbled upon Scott Peterson’s awesome MusicBrainz-Sharp library and I’ve been talking to him re: some issues it has, but so far it’s been great help. Kudos to you, Scott!
Suggestions, comments, etc? Feel free to leave a comment!
(And here I thought MBTagger/Picard were slow… and it’s MusicBrainz.Org forcing you to do 1 query per second. Is it time to implement a separate server cache? Hrm… Maybe.)
Open-Source GPS
Oct 7th
Being sick of all the commercial GPS solutions out there, I’ve decided to start coding my own GPS solution – with autorouting and all! Let’s see how this goes…
So far I’ve already coded the NMEA/GPS integration. Took me about 30m to write it up; should be fun. IMO the hardest part will be getting the maps to work. Any takers on reverse engineering Destinator/TomTom/etc formats?
Once it’s finished, it should work on all .NET enabled platforms – standard and/or Mono-based. I’ll be supporting Windows Mobile as the standard mobile platform for development.
Drop me a line.