If you need the icons for files in a Windows program, the easiest way to do so is with the system image list. This is an image list (a resource containing icons, mapped by index) that caches those system icons. The advantage of being an image list is you can easily associate it with a control (like a ListView) and pick out the images by their index, or draw out of it.Continue reading
Short post: On Windows, UTF-16 was the dominant locale, and UTF-8 was something only to convert to and from. (Microsoft jumped the gun before Unicode expanded the address space.) While it got better (Windows 10 can use UTF-8 as an MBCS locale with ANSI APIs), it was historically a lot worse.
For converting, you’d use the
MultiByteToWideChar and its opposite
WideCharToMultiByte. On legacy Windows, they have slightly confusing semantics. Specifically, with flags. While Vista on introduced many flags that can be used with the UTF-8 codepage (to deal with the quirks of conversion, like invalid characters), previously only
MB_ERR_INVALID_CHARS was allowed, and only if you were running XP or 2000 SP4. Before that, you can’t have any flags if you’re converting to or from UTF-16 and UTF-8. It’s unfortunately a little dangerous, but that’s the rub.
Hot on the heels of another Git-related article that was making the rounds recently, I was reminded of Git’s own structure and how it influences user experience. Specifically what we assume is part of how Git works, is actually a part of the porcelain (in Git speak, the user interface and commands that back it). As someone developing a Git client, it’s interesting to think Git’s user experience could be significantly different with a different interface, particularly because people have a particular mental model of Git influenced by the default interface. Said influence is enough that libgit2’s API emulates the porcelain’s semantics, in-process.Continue reading
I had a simple Win32 application fail to create its window (in my case, a dialog box, using either
DialogBox). I got back the error 0x583; unable to create window class. If I forced the window style on my dialog to create regardless of errors, my dialog was empty.
It turns out I was using themed controls in my manifest, but I didn’t call
InitCommonControls. After that, my application worked.
Brief post, but I was porting a C89 project to Visual C++ 6 (don’t ask) when I found something really fun. Turns out “
long long“, the type everyone assumes is the 64-bit type in C, is actually a GCC extension. MSVC uses…
_int64, a different extension. Great, had to convert a bunch of code. You’ll get this fun error from old MSVC when it sees it:
error C2632: 'long' followed by 'long' is illegal
(Note that MSVC will probably assume your C code is C++, which does mean you get some stuff from C99 for free like single-line comments… but then initializers are different between C and C++, and C++ only added
long long in C++11…)
It’s an unfortunate gotcha for those who assume they’re writing standards compliant C89. The reason might be deflated when you have to define your own 64-bit integer with
#ifdef. Oh, and let’s not forgot “long long” could mean 72-bit on your 9-bit byte system, of course. That’s why
stdint.h exists…. except, oh, C89.
This post has been copy-edited by doppler. Thanks!
Most research nerds either start writing Unix hagiographies or start stapling a 99-point thesis at the doors of Murray Hill. This is the latter kind of post; I’ll try to cover ideas for systems that could be meaningfully different from current systems. I’ve done a lot of research on existing concepts and existing systems, particularly those that could have been the future. Existing systems can be extrapolated into something new.
A lot of the ideas have been percolating in my head for a while now and are rough ideas for what could be. Perhaps I’ll iterate on them further, or realize there’s a reason no one was doing these before. The main idea is a place to start off, and it iterates from there. Treat it like a buffet of ideas; caveat emptor for people who don’t like musing.Continue reading