Let's review. Suppose you have a file with 1-byte name, "\xa1". IIUC that when getOpenFile returns this file, it returns 2-byte string, something like "\xc0\xa1", without utf8 flag, is that correct? In this case, getOpenFile seems to be flawed, and you probably should find how to make it return exact file name, without converting it to utf8.