Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unportable string handling in API #19

Open
alamaison opened this issue May 30, 2016 · 2 comments
Open

Unportable string handling in API #19

alamaison opened this issue May 30, 2016 · 2 comments

Comments

@alamaison
Copy link

The way char vs wchar_t strings are handled on Windows makes hard to write portable code. Currently, if UNICODE is defined the API is wide and if not it is narrow. On POSIX it is always narrow.

The only way to write portable code with this API is to use the preprocessor to select completely separate implementations based on #ifdef UNICODE.

Instead both narrow and wide versions should always be defined and it is up to the caller which they use.

The problem did not exist in previous versions of Boost.Process.

@klemens-morgenstern
Copy link

You can pull this from my fork, where it's templated. Thus it allows char and wchar_t on windows.

Do you know if anyone actually uses the wchar_t variants? I am working on a new version, but I completely removed them, because I never touch them.

@alamaison
Copy link
Author

You can pull this from my fork, where it's templated

Thanks.

Do you know if anyone actually uses the wchar_t variants?

You have to on Windows if you want Unicode because the narrow API doesn't support UTF-8. Unless you do something like Boost.Filesystem that allows you to pass a locale which can be set to interpret narrow strings as UTF-8. Or like Boost.Locale that always assumed narrow strings are UTF-8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants