Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use a Unicode "argv"?

I'm writing a little wrapper for an application that uses files as arguments.

The wrapper needs to be in Unicode, so I'm using wchar_t for the characters and strings I have. Now I find myself in a problem, I need to have the arguments of the program in a array of wchar_t's and in a wchar_t string.

Is it possible? I'm defining the main function as

int main(int argc, char *argv[])

Should I use wchar_t's for argv?

Thank you very much, I seem not to find useful info on how to use Unicode properly in C.

like image 931
John Avatar asked Nov 03 '09 00:11

John


People also ask

What format is argv?

argv(ARGument Vector) is array of character pointers listing all the arguments. If argc is greater than zero,the array elements from argv[0] to argv[argc-1] will contain pointers to strings. Argv[0] is the name of the program , After that till argv[argc-1] every element is command -line arguments.

What's the difference between argv and argc?

The first parameter, argc (argument count) is an integer that indicates how many arguments were entered on the command line when the program was started. The second parameter, argv (argument vector), is an array of pointers to arrays of character objects.

What is argv command?

argv is the list of commandline arguments passed to the Python program. argv represents all the items that come along via the command line input, it's basically an array holding the command line arguments of our program. Don't forget that the counting starts at zero (0) not one (1).

What is argv return?

The ARGV() function returns the arguments passed to PRO/5 when invoked. ARGC returns the number of arguments passed on the command line. ARGV(0) always returns the fully qualified name of the PRO/5 executable. User-defined arguments are returned in ARGV(1), ARGV(2), etc., up to ARGV(ARGC-1).


1 Answers

Portable code doesn't support it. Windows (for example) supports using wmain instead of main, in which case argv is passed as wide characters.

like image 157
Jerry Coffin Avatar answered Sep 24 '22 11:09

Jerry Coffin