aboutsummaryrefslogtreecommitdiff
path: root/include/charset.h
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-03-07 19:43:00 -0500
committerTom Rini <trini@konsulko.com>2021-03-07 19:43:00 -0500
commit90964ab5acb29ec6617a9ff340886230b2fce8c7 (patch)
treefab87d3307e5c4902c07ff4ab630a9a709bc6daa /include/charset.h
parente4dba4ba6f61e8128be0b4200ca2d8cebf62180b (diff)
parent7d3eff3412886f277c724a9effcbe545c4cdd5b5 (diff)
Merge tag 'efi-2021-04-rc3-3' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request for efi-2021-04-rc3-3 New: * Provide library functions for converting UTF-8 streams either to code page 437 or Unicode code points. Bug fixes: * Fix the capsule update unit tests. * Use the terminal size of the video console if it is the primary output.
Diffstat (limited to 'include/charset.h')
-rw-r--r--include/charset.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/charset.h b/include/charset.h
index cc650a2ce7..a911160f19 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -14,6 +14,11 @@
#define MAX_UTF8_PER_UTF16 3
/**
+ * codepage_437 - Unicode to codepage 437 translation table
+ */
+extern const u16 codepage_437[128];
+
+/**
* console_read_unicode() - read Unicode code point from console
*
* @code: pointer to store Unicode code point
@@ -270,4 +275,33 @@ u16 *u16_strdup(const void *src);
*/
uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size);
+/**
+ * utf_to_cp() - translate Unicode code point to 8bit codepage
+ *
+ * Codepoints that do not exist in the codepage are rendered as question mark.
+ *
+ * @c: pointer to Unicode code point to be translated
+ * @codepage: Unicode to codepage translation table
+ * Return: 0 on success, -ENOENT if codepoint cannot be translated
+ */
+int utf_to_cp(s32 *c, const u16 *codepage);
+
+/**
+ * utf8_to_cp437_stream() - convert UTF-8 stream to codepage 437
+ *
+ * @c: next UTF-8 character to convert
+ * @buffer: buffer, at least 5 characters
+ * Return: next codepage 437 character or 0
+ */
+int utf8_to_cp437_stream(u8 c, char *buffer);
+
+/**
+ * utf8_to_utf32_stream() - convert UTF-8 stream to UTF-32
+ *
+ * @c: next UTF-8 character to convert
+ * @buffer: buffer, at least 5 characters
+ * Return: next codepage 437 character or 0
+ */
+int utf8_to_utf32_stream(u8 c, char *buffer);
+
#endif /* __CHARSET_H_ */