Bento4
Bento4 copied to clipboard
How can I open a AP4_FileByteStream from a UTF-16 Japanese file name?
I apologize for filing this under "issues" but I can't figure out how to create a AP4_FileByteStream object from a UTF-16 filename (Japanese characters) that cannot be converted to a ANSI string (on Windows)? I've tried using GetShortPathName (and FindFirstFile) but there's no short name set for the files I'm looking at. Any help would be appreciated. Thanks, -Gianluca.
The input string should be encoded as UTF-8. So if you have the file name as UTF-16, you need to convert that to UTF-8 first.
Hi Gilles,
I tried using windows' MultiByteToWideChar to convert the filename from UTF-16 to UTF-8, but fopen_s still failed.
I think that fopen_s on Windows only takes a multibyte (ANSI) string.
I tried implementing a second AP4_StdcFileByteStream::Create which takes a UTF-16 filename and then uses _wfopen_s and wcscmp, and everything works.
Would it make sense to put that in the official implementation?
-Gianluca.
Sorry about that, I though UTF-8 was supported, but it isn't (I was confusing with another open source project I maintain where that's supported). I'll add support for it.
hello @gmacciocca could share your version / pull-request so i could take a look, i was also wanting to implement the same in my mp4decrypt.
Quick comment: UTF-8 should be supported in recent versions. It is still somewhat tricky to use that for command-line applications, because the Windows shell/console doesn't really pass the command line arguments as UTF-8, so it is hard to get the right value for those tools. But if you use the API and pass a UTF-8 encoded string, everything should work as expected.