Left (and right) facing quote marks

I work on a program called Mixbus which uses an older version of glib (ver 2). Recently, a Danish customer complained that when he uses left (or right) single quote characters in a file name, Mixbus doesn’t recognise them. So the word I’ve will get recognised (because it uses an apostrophe) whereas I’ve wouldn’t work because it uses a right-hand quote mark. Unfortunately, this site seems to display them both the same (on my monitor, at least) so just trust me - they’re different strings… and I’m told that LH and RH marks are used commonly in Denmark. So I tried this code, just for testing purposes:-

gchar xx[4];
GError* err = NULL;

xx[0] = 0xe2;
xx[1] = 0x80;
xx[2] = 0x99;
xx[3] = 0;

wchar_t* wquote = (wchar_t*)g_utf8_to_utf16 ((const gchar*)&xx, -1, NULL, NULL, &err);

Albeit kludgy, this does give me a utf16 string consisting of a single right-hand quote mark. Keep in mind that my code page (UK) doesn’t contain a right-hand quote mark as a single character - but I assumed I’d be able to use g_utf16_to_utf8() to convert it to a a single right-hand quote mark in utf8 format - something like this maybe:-

gchar* quote = (gchar*)g_utf16_to_utf8 ((const gunichar2 *)&wquote, 1, NULL, NULL, &err);

But after a couple of hours experimenting, I can’t find any way to make g_utf16_to_utf8() return a right-hand quote mark. Is that because utf8 doesn’t offer that character either? Or does it maybe involve my Windows character map & code page (and therefore, if they don’t contain the RH mark, utf8 won’t either?)

Doh! A good night’s sleep solved it! I needed to change this…

gchar* quote = (gchar*)g_utf16_to_utf8 ((const gunichar2 *)&wquote, 1, NULL, NULL, &err);

to this…

gchar* quote = (gchar*)g_utf16_to_utf8 ((const gunichar2 *)wquote, 1, NULL, NULL, &err);
1 Like