In the end I managed to track the problem down to the way I was outputing the string with OutputDebugString in VS. If I saved the resulting string (given by GetString()), the output was as expected!
OutputDebugString
GetString()
Foiled by the debug trap I was!