waterlan schreef op 2015-07-07 20:40:
> Hi,
> 
> My console application (dos2unix) has globbing enabled:
> 
> 
> int main (int argc, char *argv[])
> {
> # ifdef __MINGW64__
>    int _dowildcard = -1; /* enable wildcard expansion for Win64 */
> # endif
> 
> 
> This works fine for ANSI names. But, in order to open files with 
> unicode
> names, I'm converting the arguments to wide arguments.
> 
> 
>    wchar_t **wargv;
>    wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
> 
> 
> The wide arguments wargv are not globbed. When I try to open files, I
> get this kind of errors:
> 
> 
> c:\tmp>dos2unix *.txt
>   *.txt: No such file or directory
> 
> 
> Is there a way to get a globbed file list of wide arguments in a 
> console
> application?

Hi,

I solved it by making my own wide globbing function. I take the wide 
arguments from CommandLineToArgvW(), I glob them and convert the result 
to UTF-8. The function returns a normal char** type arg list with all 
the file names in UTF-8 encoding. Because all the program's command line 
options are ASCII, I don't need to change anything in the command line 
parsing function. On the few places where I access the file system I 
created small wrapper functions that convert the UTF-8 file names back 
to wchar_t names, so I can use the wide functions to access the files 
(e.g. _wfopen instead of fopen). This way the change to my code was 
minimal and stays portable.

If you want to see the code check out the latest version of dos2unix 
(7.3-beta5).

best regards,

-- 
Erwin Waterlander
http://waterlan.home.xs4all.nl/

------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to