0

I am writing a console program that processes files passed by the user as launch arguments (reads, processes in a certain way, writes to other files). The problem is that file paths can contain chinese, german, ukrainian and other non-standard letters, which are incorrectly processed by the program (impossible to open files due to an incorrect path). I can use 'wmain' and 'wchar_t** argv' instead of 'main' and 'char** argv', but I haven't seen any library for argument parsing that supports wchar_t argv, and I, besides paths, have to parse many more parameters of different types.

Tell me, please:

  1. Is it possible to get by with exclusively ordinary char when processing paths containing non-ascii characters?
  2. Do you know any argument parsing libraries that support 'wmain'? (most popular, 'argparse', doesn`t support it.)
asked Oct 29, 2022 at 8:55
6
  • Regarding #1 you cannot do anything at all until you know what encoding your non-ASCII characters are represented by. This crucial information is missing from the description above. Do you know the encoding? Commented Oct 29, 2022 at 9:03
  • Dou you mean replacements for strcmp(), strlen(), and such? Don't wcscmp(), wcslen() and related (in <wchar.h>, or <cwchar> in C++) work for you? Commented Oct 29, 2022 at 9:07
  • @Paulo1205 no, I don't mean that. I described exactly what the problem is: I either can’t parse the rest of the arguments (since there is no parsing library that supports wmain), or I can’t get paths from argv if they contain non-ascii characters Commented Oct 29, 2022 at 9:15
  • 1
    @Chase, if you cannot find a library, you can make your own with the building blocks I suggested. Also, you can probably get at least a little further with regular char-based libraries if you properly configure locale in your program, but YMMV. Finally, with a simple Google, I found about a version of getopt that was ported to Unicode (codeproject.com/Articles/157001/…) Would that work for you? Commented Oct 29, 2022 at 9:32
  • 2
    boost::program_options support wchar_t. Googling "wchar_t getopt" returns quite a bit of results too. Commented Oct 29, 2022 at 9:33

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.