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

Avoid non-ascii characters in catch.hpp #1542

Closed
autocompile opened this issue Feb 15, 2019 · 1 comment
Closed

Avoid non-ascii characters in catch.hpp #1542

autocompile opened this issue Feb 15, 2019 · 1 comment

Comments

@autocompile
Copy link

Describe the bug
When compiling with Visual Studio (using compound single-file catch.hpp) with /W4, Visual Studio warns about non-ascii character found in catch.hpp.
NOTE: I'm NOT using an English version of Windows.

Expected behavior
Don't use non-ascii characters in Catch source files... as they are not necessary.

Reproduction steps
Just

#define CATCH_CONFIG_MAIN
#include "./catch.hpp"

is enough to trigger the VS warning.

Platform information:

  • OS: Windows 10
  • Compiler+version: Visual Studio 2017 15.9.7
  • Catch version: v2.6.1

Additional context
Non-ascii characters exists in 2 lines of compound single-file catch.hpp (v2.6.1):

@@ -3815,7 +3815,7 @@ namespace Generators {
     template<typename L>
     // Note: The type after -> is weird, because VS2015 cannot parse
     //       the expression used in the typedef inside, when it is in
-    //       return type. Yeah, ¯\_(ツ)_/¯
+    //       return type. Yeah.
     auto generate( SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) {
         using UnderlyingType = typename decltype(generatorExpression())::type;

@@ -13315,7 +13315,7 @@ public:
         case Unit::Nanoseconds:
             return "ns";
         case Unit::Microseconds:
-            return "µs";
+            return "us";
         case Unit::Milliseconds:
             return "ms";
         case Unit::Seconds:

For the first occurrence, just remove the emoticon in the comment.
For the second occurrence, consider two ways:

    1. As the diff above shows, use English letter u instead of Greek letter µ. It's clear for users to understand us refers to microseconds.
    1. Use an escape sequence for Greek letter µ, like return "\x????s";. But you have to choose an encoding first.

Personally, I strongly suggest the first approach, since the bytes presentation of µ may vary among encodings.

@horenmar
Copy link
Member

Oh well.

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

No branches or pull requests

2 participants