interec@interec.net wrote:
> Hi Folks,
>
> I am writing a c++ program on redhat linux using main(int argc,
> wchar_t *argv[]). $LANG on console is set to "en_US.UTF-8". g++
> compiler version is 3.4.6.
main(int argc,wchar_t *argv[]) is not standard. It may compile and link
but it's probably not doing what you think it does.
>
> Q1. what is the encoding of data that I get in argv[] ?
The encoding of the command line. It will probably be an 8bit /
multibyte encoding, dot a wide character (wchar_t) encoding.
>
> Q2. what is encoding of string constants defined in programs (for
> example L"--count") ?
This is a g++ question but in short, it depends on the compiler and the
encoding of the source file.
>
> Q3. when I run the program as:
>
> ./a.out --count 1
>
> Why does (wcscmp(argv[1], L"--count") == 0) always evaluate to
> false?
> What is the workaround. How do I make it evaluate to true?
Don't use what_t
>
> Q4: when I do wstring
>
> mystring = argv[1];
>
> is mystring considered to be a UTF-8 string?
try it and see.
>
>
> Q5: In case I use main(int argc, char** argv),
>
> what is the encoding of characters in argv[] ?
The encoding the caller put in there.
>
> Q6. What is the difference between main(int arc, wchar_t *argv[]) and
> main(int argc, char *argv[]). Any document that describes this? My
> compiler is gcc 3.4.6
Check with the GCC docs, but I don't think main(int arc, wchar_t
*argv[]) is supported at all.
>
> Thanks
>