]> Git Repo - J-u-boot.git/blobdiff - lib/charset.c
Merge tag 'u-boot-dfu-20240930' of https://source.denx.de/u-boot/custodians/u-boot-dfu
[J-u-boot.git] / lib / charset.c
index 5e4c4f948a4a2570649d4b83cac405539c3fc6b2..182c92a50c4866de635d9320b9c097d76bb47877 100644 (file)
@@ -5,7 +5,6 @@
  *  Copyright (c) 2017 Rob Clark
  */
 
-#include <common.h>
 #include <charset.h>
 #include <capitalization.h>
 #include <cp437.h>
@@ -16,7 +15,7 @@
 /**
  * codepage_437 - Unicode to codepage 437 translation table
  */
-const u16 codepage_437[128] = CP437;
+const u16 codepage_437[160] = CP437;
 
 static struct capitalization_table capitalization_table[] =
 #ifdef CONFIG_EFI_UNICODE_CAPITALIZATION
@@ -388,7 +387,7 @@ int u16_strcasecmp(const u16 *s1, const u16 *s2)
  *             > 0 if the first different u16 in s1 is greater than the
  *             corresponding u16 in s2
  */
-int u16_strncmp(const u16 *s1, const u16 *s2, size_t n)
+int __efi_runtime u16_strncmp(const u16 *s1, const u16 *s2, size_t n)
 {
        int ret = 0;
 
@@ -517,9 +516,12 @@ int utf_to_cp(s32 *c, const u16 *codepage)
                int j;
 
                /* Look up codepage translation */
-               for (j = 0; j < 0x80; ++j) {
+               for (j = 0; j < 0xA0; ++j) {
                        if (*c == codepage[j]) {
-                               *c = j + 0x80;
+                               if (j < 0x20)
+                                       *c = j;
+                               else
+                                       *c = j + 0x60;
                                return 0;
                        }
                }
@@ -571,6 +573,10 @@ int utf8_to_utf32_stream(u8 c, char *buffer)
                }
                if (pos == end)
                        return 0;
+               /*
+                * Appending the byte lead to an invalid UTF-8 byte sequence.
+                * Consider it as the start of a new code sequence.
+                */
                *buffer = 0;
        }
 }
This page took 0.027605 seconds and 4 git commands to generate.