There's some weird issue with my program that's been torturing me for like 2 hours. This is my last day and I need to get this done ASAP, and I don't know anyone personally who doesn't suggest stupid things like "does your compiler support Unicode?" "does your terminal support Unicode?" "have you tried recompiling/restarting your computer?"
Anyway, I have this specific issue with wcout. When printing any box drawing character (e.g. ┌) it completely stops working. As in, wcout can no longer be used. It shuts down, freezes, whatever.
However, printf, wprintf, and even regular cout still work with box drawing characters. They have no issue.
What's going on here? Can someone please help me with this?
It works for me on Linux (Debian), and prints "You will not see me" over and over again, except for the output on line 15 that is not printed. Apparently, you're not supposed to mix wide and narrow characters when outputting to stdout. If I change line 15 to use wide characters it works fine.
I'm (or rather my IDE is) using clang on macOS 10.14.
Do you know if you're using libstdc++ or libc++? A quick search seems to suggest that there are some problems with libstdc++'s handling of locales on mac.
user657267 wrote:
As libstdc++ does not support anything but the 'generic' locale model on OSX, C++ locales are hardly supported at all. Your segfault is caused by facet.table(); returning a null pointer (this is not actually allowed by the standard).
if you're using libstdc++ you should know that it doesn't support locales properly on OS X. You'll have to use libc++ in order for OS X's locale names (e.g., "en_US.UTF-8") to work.
Do you know if you're using libstdc++ or libc++? A quick search seems to suggest that there are some problems with libstdc++'s handling of locales on mac.
Changing the stdlib doesn't change the behavior. Changing the compiler to clang++ causes iostream to not be found.
I used GCC on Linux (Debian).
Using GCC on macOS yields the same, wcout-less result. I don't know what's going on...
You asked what the string returned by setlocale said, that's the entire string.
You did nothing wrong. I was just hoping that it would say "C", or be a null pointer, something that's obviously wrong. For me it returns a single locale name ("en_US.utf8") so I don't know how to interpret all those slash separated Cs.
My entire library uses wstring rather than string.
OK, well, I'm afraid I won't be able to help you. Hopefully someone who has more experience with wide characters on MacOS can be of more help.
About your problems with clang++... this is just a shot in the dark, but did you read the comments posted below on this SO answer? https://stackoverflow.com/a/25141428/8690169
(It's from the same page that Peter linked.)
If the problem is that it can't find standard library headers like <iostream>, it that sounds fixable: