-
Notifications
You must be signed in to change notification settings - Fork 582
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
error parsing options: Option ‘t’ does not exist #34
Comments
Same here. When options.parse encounters an option that it doesn't recognize, it's throwing an option_not_exists_exception. The output of that exception (using I'm on Visual Studio Basic 2015 on Windows 10 x64 |
Well that's different. Technically the output is not lying, but it's probably also not what you want 😛 |
Well this is going to make life difficult. I can't reproduce this on Linux, and I don't have access to a Windows machine. Do you have a tool like Valgrind that you can run it with? That or if you're able to run it in a debugger and provide me with some more output then that will help me track this down. |
I can do some debugging later (maybe tomorrow). |
Ok, so actually, the option name isn't being trashed, but instead, it's the and the beginning of the string. Notice after the "£" is the character "x", which is the option I used to test with: @mulderp 's message ( Looking at how that string is constructed, we see this:
if I step in, the debugger goes the operator+ function for the string. The left operand is "Option ‘" and the right operand is "x". This makes me think that Windows, VS2015, or both, do not like the single quote's that are a part of the exception string. After replacing the
I'll make the changes and submit a pull request. |
nice - indeed removing the quotes solves it on windows :) |
Windows is clearly deficient at displaying UTF-8 encoded code points. Is this running in the command prompt or in your IDE? Can you set the encoding somewhere and see if it makes any difference? If it's as difficult as stack overflow suggests, then expecting Windows to behave sensibly is next to impossible. I don't really want to throw out the nice quotes just because Windows doesn't know how to display them. A better fix would be to use normal quotes just for Windows. |
Hi. Someone mentioned this little lib on reddit.com/r/cpp and I decided to have a look. Of course, I am following gospel of http://utf8everywhere.org and of course I immediately ran into this issue on Windows. Anyways, after spending an hour digging in this solution was found. Here is it for your convenience and enlightenment:
So, for greatest simplicity -- just use utf-8 everywhere:
Read up on all this here: P.S. Keep in mind that your editor still could be retarded. For example, MSVC2015 can't copy paste that fancy "quote" character used by this library -- it mangles it (verified with binary editor). Maybe because it was working with my file expecting Latin-1 encoding. I should try adding BOM to it and try again. P.P.S. I went back and checked that copy-paste problem -- when Visual Studio detects correct encoding (as identified by selection in File/Advanced Save Options...) copy-paste works fine. But if file (you are pasting to) was open using some other encoding -- it'll likely mangle it (will try to convert symbols from source file encoding to target file encoding). |
Thanks for the details. I'll close this issue shortly given that 1. Windows uses retarded defaults, and 2. there are ways to make it work properly. That said, is there anything I can do in this code to help? Would putting a BOM in help here? I use UTF-8 everywhere, but in Linux it just works. |
On Linux it works because by default everything is considered to be utf-8 encoded. Windows carries a lot of baggage from the past -- I bet they'll need at least two more major releases to get rid of it. No, adding BOM to your file won't help. MSVC (and it's compiler) already recognizes utf-8 encoding when it stumbles upon your magical quote symbols. Your users need to be aware of how to deal with this (i.e. they need to go through steps I mentioned). |
Ok thanks for the info. |
Turned out you also need this (starting from Windows 10):
Unfortunately this also means that there is still a chance of screwing up your output if you fill buffer completely before next flush. Proper solution -- flush it manually ( |
I get a strange strings when running this code without a valid option:
Build is on Windows with MSVC community 15
The text was updated successfully, but these errors were encountered: