Erik de Castro Lopo
2013-Mar-17 10:37 UTC
[flac-dev] Patch to add Unicode filename support for win32 flac
JonY wrote:> On 3/17/2013 10:33, Janne Hyv?rinen wrote: > > Here's a patch that makes MSVC compiled flac.exe able to use wildcards > > and encode/decode files with Unicode characters in names. It may not be > > the prettiest code but it fulfills its primary purpose. > > I tried to alter FLAC code as little as possible. It replaces argv with > > utf-8 encoded version and only converts to usable Unicode for file > > functions. That means printed texts and tags that contain non-ascii > > characters will be broken, but it is fixable if these changes are > > acceptable. > > > > Can this be reworked without the defines? This way, it should support > mingw builds too.+1 I'd like to see some way to do this to: a) Make this usable from MinGW compiled binaries. b) Reduce the the amount of inline #ifdef hackery. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
JonY
2013-Mar-17 14:55 UTC
[flac-dev] Patch to add Unicode filename support for win32 flac
On 3/17/2013 18:37, Erik de Castro Lopo wrote:> JonY wrote: > >> On 3/17/2013 10:33, Janne Hyv?rinen wrote: >>> Here's a patch that makes MSVC compiled flac.exe able to use wildcards >>> and encode/decode files with Unicode characters in names. It may not be >>> the prettiest code but it fulfills its primary purpose. >>> I tried to alter FLAC code as little as possible. It replaces argv with >>> utf-8 encoded version and only converts to usable Unicode for file >>> functions. That means printed texts and tags that contain non-ascii >>> characters will be broken, but it is fixable if these changes are >>> acceptable. >>> >> >> Can this be reworked without the defines? This way, it should support >> mingw builds too. > > +1 > > I'd like to see some way to do this to: > > a) Make this usable from MinGW compiled binaries. > b) Reduce the the amount of inline #ifdef hackery. >A simple way to do this is to make all C IO calls that need OS specific hacks go into the compatibility module. Eg for open() calls: int _flac_open(....){ #if win32 ... #else if os2 ... #else ... [generic call to open() without hacks] #endif } All those ifdefs will at least be confined rather than spread out through the code. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 834 bytes Desc: OpenPGP digital signature Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20130317/8e31387b/attachment.pgp
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 17.03.2013 18:55, JonY wrote:> On 3/17/2013 18:37, Erik de Castro Lopo wrote: >> JonY wrote: >> >>> On 3/17/2013 10:33, Janne Hyv?rinen wrote: >>>> Here's a patch that makes MSVC compiled flac.exe able to use >>>> wildcards and encode/decode files with Unicode characters in >>>> names. It may not be the prettiest code but it fulfills its >>>> primary purpose. I tried to alter FLAC code as little as >>>> possible. It replaces argv with utf-8 encoded version and >>>> only converts to usable Unicode for file functions. That >>>> means printed texts and tags that contain non-ascii >>>> characters will be broken, but it is fixable if these changes >>>> are acceptable. >>>> >>> >>> Can this be reworked without the defines? This way, it should >>> support mingw builds too. >> >> +1 >> >> I'd like to see some way to do this to: >> >> a) Make this usable from MinGW compiled binaries. b) Reduce the >> the amount of inline #ifdef hackery. >> > > A simple way to do this is to make all C IO calls that need OS > specific hacks go into the compatibility module. Eg for open() > calls: > > int _flac_open(....){ #if win32 ... #else if os2 ... #else ... > [generic call to open() without hacks] #endif } > > All those ifdefs will at least be confined rather than spread out > through the code.I did it plibc-style: in compat.h: #if defined(_WIN32) #define FOPEN grabbag__fopen_utf8_wrapper #else #define FOPEN fopen #endif in grabbag: #if defined(_WIN32) <implement grabbag__fopen_utf8_wrapper, which has the same signature as fopen, but does utf8->utf16 conversion internally, then calls wfopen> #endif and replace "fopen" with "FOPEN" everywhere else. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJRRdrIAAoJEOs4Jb6SI2CwL4YH/Ayixx9r3XitYI0j1FH+xQd3 lrhJ3I3Di1uE0/LES9/mL65T6yBvwov1LDoL4JMHMK4/mH78s0wDZXYr6h/FoEhW 8XpxRL6ujDfCEb2cp76KAcZLL3rcO4uEsgVJsXBtkC5K+zpjzgMVnasg+oH/Z6sS PdqPg/w+40FOgkYszMUwwJJJF/y2uTZXSOZoDyM8glx2oMhrAHmi0Yx7ksehndSo wN6JaJFe3IdprOZdyLXpxsPxiNt1MiR0b7BKg4bAFt8evStcD9d/CHSJ3te5134v d4YswJj/GQ1y9fJLpW+wPSEYmcJbi+Brkfo8OYs5pcs2Tsv0ZfQ80ItoJZ91CyQ=ZnwK -----END PGP SIGNATURE-----
Reasonably Related Threads
- Patch to add Unicode filename support for win32 flac
- Patch to add Unicode filename support for win32 flac
- Patch to add Unicode filename support for win32 flac
- Patch to add Unicode filename support for win32 flac
- Patch to add Unicode filename support for win32 flac