build: include config.h manually
[platform/upstream/libxkbcommon.git] / src / utf8.c
index 11382c8..15aa237 100644 (file)
@@ -24,6 +24,8 @@
  * Author: Rob Bradford <rob@linux.intel.com>
  */
 
+#include "config.h"
+
 #include <stddef.h>
 #include <stdbool.h>
 #include <inttypes.h>
@@ -49,17 +51,13 @@ utf32_to_utf8(uint32_t unichar, char *buffer)
         length = 3;
         head = 0xe0;
     }
-    else if (unichar <= 0x1fffff) {
+    else if (unichar <= 0x10ffff) {
         length = 4;
         head = 0xf0;
     }
-    else if (unichar <= 0x3ffffff) {
-        length = 5;
-        head = 0xf8;
-    }
     else {
-        length = 6;
-        head = 0xfc;
+        buffer[0] = '\0';
+        return 0;
     }
 
     for (count = length - 1, shift = 0; count > 0; count--, shift += 6)
@@ -80,7 +78,7 @@ is_valid_utf8(const char *ss, size_t len)
 
     /* This beauty is from:
      *  The Unicode Standard Version 6.2 - Core Specification, Table 3.7
-     *  http://www.unicode.org/versions/Unicode6.2.0/ch03.pdf#G7404
+     *  https://www.unicode.org/versions/Unicode6.2.0/ch03.pdf#G7404
      * We can optimize if needed. */
     while (i < len)
     {