fork download
  1. #define PER_MILLE_SIGN "\u2030"
  2.  
  3. #define CODEPOINT_(x) * U ## x // Prepend char32_t prefix, get first element of string literal.
  4. #define CODEPOINT(x) CODEPOINT_(x) // Tame catenation operator.
  5.  
  6. wchar_t *s1 = L"" PER_MILLE_SIGN;
  7. char *s2 = "123 " PER_MILLE_SIGN;
  8. constexpr char16_t c{ CODEPOINT( PER_MILLE_SIGN ) }; // Narrowing safe; CODEPOINT is constant expression.
  9.  
  10. #include <iostream>
  11.  
  12. int main() {
  13. switch ( 0x2030 ) {
  14. case c: std::cout << s2 << '\n';
  15. }
  16. }
  17.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
123 ‰