lib: rational: copy the rational fraction lib routines from Linux
[platform/kernel/u-boot.git] / include / charset.h
index 5564f3b..b93d023 100644 (file)
 
 #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
  *
@@ -219,7 +224,7 @@ size_t u16_strlen(const void *in);
 size_t u16_strsize(const void *in);
 
 /**
- * u16_strlen - count non-zero words
+ * u16_strnlen() - count non-zero words
  *
  * This function matches wscnlen_s() if the -fshort-wchar compiler flag is set.
  * In the EFI context we explicitly need a function handling u16 strings.
@@ -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_ */