xiph/vorbis

Vorbisfile fails to Open A Unicode String Filename (Windows)

atkawa7 opened this issue · 5 comments

On these lines https://github.com/xiph/vorbis/blob/master/lib/vorbisfile.c#L1009-L1017. Had to add an additional method on windows.

#ifdef _WIN32
int ov_wfopen(const wchar_t *path, OggVorbis_File *vf)
{
        int ret;
        FILE *f = _wfopen(path, L"rb");
        if (!f)
                return -1;

        ret = ov_open(f, vf, NULL, 0);
        if (ret)
                fclose(f);
        return ret;
}
#endif
erikd commented

VorbisFile uses UTF-8 Unicode, not Windows' UTF-16.

@erikd True. Its utf-16. Miss communication on my part.

erikd commented

I maintain another library much like Vorbis. To address this issue, Windows users convert the UTF-`6 file name to UTF-8 before passing it to my library. I don't program on Windows so I have no idea how this is done.

@erikd I had tried doing it before but it doesn't work. I pass in const char * from a method that converts wchar_t* to char* it returns an error. The other codecs (opus/flac ) works fine. So I think there must be an issue with that ov_fopen method