/**
* read_console() - read byte from console
*
- * @src - not used, needed to match interface
- * Return: - byte read
+ * @data - not used, needed to match interface
+ * Return: - byte read or 0 on error
*/
static u8 read_console(void *data)
{
- return getc();
+ int ch;
+
+ ch = getc();
+ if (ch < 0)
+ ch = 0;
+ return ch;
}
int console_read_unicode(s32 *code)
return i;
}
+u16 *u16_strcpy(u16 *dest, const u16 *src)
+{
+ u16 *tmp = dest;
+
+ for (;; dest++, src++) {
+ *dest = *src;
+ if (!*src)
+ break;
+ }
+
+ return tmp;
+}
+
+u16 *u16_strdup(const u16 *src)
+{
+ u16 *new;
+
+ if (!src)
+ return NULL;
+
+ new = malloc((u16_strlen(src) + 1) * sizeof(u16));
+ if (!new)
+ return NULL;
+
+ u16_strcpy(new, src);
+
+ return new;
+}
+
/* Convert UTF-16 to UTF-8. */
uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)
{