Sign in to follow this  
FFMG

boost::program_options::value... UNICODE?

Recommended Posts

Hi, I would like to pass a path as one of my command line argument. But it is not impossible that some of my users will have some unicode characters in the path. But I don't see to be able to add the option, add_options( "path", boost::program_options::value<const wchar_t*>(), "The path" ) Am I missing something? Is it not possible to pass unicode characters via command line, (I am programming a windows App)? Many thanks FFMG

Share this post


Link to post
Share on other sites
Unocide Support.

Also, use wstring, I don't think char arrays work well with these libraries, they definitely make memory management difficult.

And to parse command line arguments, it's also necessary to use proper main() signature, and build the project with unicode support.

Share this post


Link to post
Share on other sites
Quote:
Original post by Antheus
Unocide Support.


I have the right settings for my compiler, (VS2008).

And, according to the doc, it says, "For example, the parse_command_line function has an overload which takes wchar_t strings, instead of ordinary char.", so it should work as far as I understand it.

Quote:

Also, use wstring, I don't think char arrays work well with these libraries, they definitely make memory management difficult.


Hum, add_options( "path", boost::program_options::value<std::wstring>(), "The path" )
Doesn't work either ...

Quote:

And to parse command line arguments, it's also necessary to use proper main() signature, and build the project with unicode support.


Yet, I have that.
I must be missing something else.

FFMG

Share this post


Link to post
Share on other sites
Quote:
Original post by FFMG
Quote:

And to parse command line arguments, it's also necessary to use proper main() signature, and build the project with unicode support.


Yet, I have that.
I must be missing something else.


What I was missing was the definition, it should be

boost::program_options::wvalue<std::wstring>() instead of boost::program_options::value<std::wstring>()

FFMG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this