On Tue, Jul 05, 2011 at 01:52:06PM -0400, Todd C. Miller wrote: > Also, what is that > 'L' doing there before the "foobar"? Is it some sort of wide char > thing I'm not aware of? >
L"" is C99 notation for wide character string literals. wchar_t is an int, so a pointer increment will consume 4 bytes, not 1. L"foobar" results in the byte string: "f\0\0\0o\0\0\0o\0\0\0b\0\0\0a\0\0\0r\0\0\0\0\0\0\0" The standard says the multibyte-encoding used by L"" is implementation-defined. I am not entirely sure what rules our various gcc versions apply. L"" might not work in all locales on OpenBSD. So generally it's better to use something like mbstowcs() instead of L"". Conversion performed at runtime will always be correct for the active locale.