cginternals / globjects

C++ library strictly wrapping OpenGL objects.
https://globjects.org
MIT License
538 stars 59 forks source link

std::isspace does not work on some unicode chars, breaks IncludeProcessor #316

Open karyon opened 7 years ago

karyon commented 7 years ago

this line here https://github.com/cginternals/globjects/blob/17dcc4c5129259781bdb9251294518f2a0c75472/source/globjects/source/IncludeProcessor.cpp#L24

was failing for me in debug mode when processing a line that had this comment inside it:

// ¯\_(ツ)_/¯

this is also mentioned in the comments of the linked stackoverflow post.

scheibel commented 7 years ago

So you suggest and vote for creating a unicode-aware fallback. Although I find unicode code slightly strange (and so is this comment above), I am pro UTF-8 encoded source code files. I also think the fallback implementation should be able to handle all cases the driver hasn't implemented (yet).

Is the isspace call the only non-unicode handling code or would a fix here imply many other fixes to get actually useful? Can you provide a pull request?

karyon commented 7 years ago

no idea whether other fixes are needed. i cannot provide a pull request at least until next year.

JavierJF commented 6 years ago

Could be possible to solve the issue including a specific locale as the second argument for std::is_space? Like:

auto wsfront = 
    std::find_if_not(s.begin(), s.end(), [](int c) { return std::isspace(c, std::locale("en_US.UTF8")); } );