Browse Source

CppLexer: Support \U escapes in addition to \u escapes

Nico Weber 5 years ago
parent
commit
c1b7fd644c
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Libraries/LibGUI/CppLexer.cpp

+ 5 - 3
Libraries/LibGUI/CppLexer.cpp

@@ -294,15 +294,17 @@ Vector<CppToken> CppLexer::lex()
             }
             return 2 + hex_digits;
         }
-        case 'u': {
+        case 'u':
+        case 'U': {
             bool is_unicode = true;
-            for (size_t i = 0; i < 4; ++i) {
+            size_t number_of_digits = peek(1) == 'u' ? 4 : 8;
+            for (size_t i = 0; i < number_of_digits; ++i) {
                 if (!isxdigit(peek(2 + i))) {
                     is_unicode = false;
                     break;
                 }
             }
-            return is_unicode ? 6 : 0;
+            return is_unicode ? 2 + number_of_digits : 0;
         }
         default:
             return 0;