globjects icon indicating copy to clipboard operation
globjects copied to clipboard

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

Open karyon opened this issue 9 years ago • 3 comments

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.

karyon avatar Nov 14 '16 13:11 karyon

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?

scheibel avatar Nov 15 '16 08:11 scheibel

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

karyon avatar Nov 21 '16 20:11 karyon

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")); } ); 

JavierJF avatar Aug 10 '18 09:08 JavierJF