get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/956559/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 956559,
    "url": "http://patchwork.ozlabs.org/api/patches/956559/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20180811152820.26817-4-xypron.glpk@gmx.de/",
    "project": {
        "id": 18,
        "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api",
        "name": "U-Boot",
        "link_name": "uboot",
        "list_id": "u-boot.lists.denx.de",
        "list_email": "u-boot@lists.denx.de",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20180811152820.26817-4-xypron.glpk@gmx.de>",
    "list_archive_url": null,
    "date": "2018-08-11T15:28:08",
    "name": "[U-Boot,03/15] lib: charset: utility functions for Unicode",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "dc9d33f39e7cfa7522225408eaa44c5820395c91",
    "submitter": {
        "id": 61270,
        "url": "http://patchwork.ozlabs.org/api/people/61270/?format=api",
        "name": "Heinrich Schuchardt",
        "email": "xypron.glpk@gmx.de"
    },
    "delegate": {
        "id": 3400,
        "url": "http://patchwork.ozlabs.org/api/users/3400/?format=api",
        "username": "agraf",
        "first_name": "Alexander",
        "last_name": "Graf",
        "email": "agraf@suse.de"
    },
    "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20180811152820.26817-4-xypron.glpk@gmx.de/mbox/",
    "series": [
        {
            "id": 60397,
            "url": "http://patchwork.ozlabs.org/api/series/60397/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=60397",
            "date": "2018-08-11T15:28:06",
            "name": "efi_loader: EFI_UNICODE_COLLATION_PROTOCOL",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/60397/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/956559/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/956559/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<u-boot-bounces@lists.denx.de>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=none (p=none dis=none) header.from=gmx.de"
        ],
        "Received": [
            "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 41nmCP3Qzmz9sBD\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 12 Aug 2018 01:30:25 +1000 (AEST)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid 24C0AC21DD3; Sat, 11 Aug 2018 15:29:41 +0000 (UTC)",
            "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 56680C21DE8;\n\tSat, 11 Aug 2018 15:28:48 +0000 (UTC)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid 5A55CC21C93; Sat, 11 Aug 2018 15:28:45 +0000 (UTC)",
            "from mout.gmx.net (mout.gmx.net [212.227.17.20])\n\tby lists.denx.de (Postfix) with ESMTPS id D757EC21C93\n\tfor <u-boot@lists.denx.de>; Sat, 11 Aug 2018 15:28:44 +0000 (UTC)",
            "from LT02.fritz.box ([88.152.14.153]) by mail.gmx.com (mrgmx102\n\t[212.227.17.174]) with ESMTPSA (Nemesis) id 0MXmpv-1fQiVB1S0F-00WjPc;\n\tSat, 11 Aug 2018 17:28:42 +0200"
        ],
        "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de",
        "X-Spam-Level": "",
        "X-Spam-Status": "No, score=0.0 required=5.0 tests=FREEMAIL_FROM\n\tautolearn=unavailable autolearn_force=no version=3.4.0",
        "From": "Heinrich Schuchardt <xypron.glpk@gmx.de>",
        "To": "Alexander Graf <agraf@suse.de>",
        "Date": "Sat, 11 Aug 2018 17:28:08 +0200",
        "Message-Id": "<20180811152820.26817-4-xypron.glpk@gmx.de>",
        "X-Mailer": "git-send-email 2.18.0",
        "In-Reply-To": "<20180811152820.26817-1-xypron.glpk@gmx.de>",
        "References": "<20180811152820.26817-1-xypron.glpk@gmx.de>",
        "X-Provags-ID": "V03:K1:eQv1JsPFpfK87J5C6QbMlTTgpVt2FI5opdmbXUD3tGS4kBDemoS\n\tkMb8lDnYOcMygeq4Cut2hdJLBsEpYSQqSnIZBKMuTQcztW2XytXmielEXR+lZsGlR4eGMGU\n\tOQN0JLJNFZxQvVPvrZ5/tG8fG9SFKMD6z42jqvr0qoOFE4OByjDm/kiwaeJKsgx2Y1oVSGy\n\thyDlUSKRxJnNnc0wCV3gA==",
        "X-UI-Out-Filterresults": "notjunk:1; V01:K0:SynOFv1TVm4=:Myp8ib0CExNOJ960kkmIe+\n\tvB1Yy/WAh51IJhAvuj4k4fVSKjEnpVw/xoFGt+9ldx+uGsPvLiuhOZqqd9kwdahb2bMvf6RmE\n\t9OY/+OzMdoOcQlQen+z+g0R2saCH83gChyF+B6pYwwW5+nnUJRuEg4LY5m4lZ9xC5tDmSeM3c\n\te4Q1xf7m93bjrLmb/lgcRsxRdUoUHDNSLggas0obGNCc5b+MbRjcpswZa5yT82DfBi1Lhb/Ni\n\t5/GGOgtFqnwJAUifDtlYyLhnJr0XHblpKVj7T75o3Tuoo/RsifKcl/h+WJg57fK97kqgliNKd\n\tan7sv3msTytkuXW04wdU4LDLrPwdyoJ1xxIFPx85W5BfsBv1cXfAHF86yCoM2w9v7Z2A/pSC7\n\tqfWOfI3los/TiraNLSpw/ANN9EB2vkzNo49rSjvbXr0BCVsoC5vazKrbjbGS0QOpvB7X7iqJZ\n\tpDpfhnyGtshNNN72luzD0K0ixQ9rJNIL6J3xW5NXKMPcwa2Xk9A/1UiRol3kFQPlc2JzRQdsL\n\ty1jvQTVQEBvt000tEQPGafP52ihAD/Zk7TndFlI3tKnRpZrWedCtODhmuWGCgJfaxJBrIbepa\n\tzlA9CLpMLpVf55AMettGFBOvbVkpl6JuJbV0jxugR90QG491Cbro3dr+i77E8q5xf41QhYtHN\n\tPeL3JnkbII3hy+q+FbSzRuSR2IOtw8cjbNEBEG1XAiJ3jKpFD6xTNZayI9i94oBcORNDXkGi4\n\tw88z+qCKLL2rBBLQpqtoBc305gX60tdyhqGfx+z8Es7GkmmQ4UMc0pB3E9Y=",
        "Cc": "Heinrich Schuchardt <xypron.glpk@gmx.de>, u-boot@lists.denx.de",
        "Subject": "[U-Boot] [PATCH 03/15] lib: charset: utility functions for Unicode",
        "X-BeenThere": "u-boot@lists.denx.de",
        "X-Mailman-Version": "2.1.18",
        "Precedence": "list",
        "List-Id": "U-Boot discussion <u-boot.lists.denx.de>",
        "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>",
        "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>",
        "List-Post": "<mailto:u-boot@lists.denx.de>",
        "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>",
        "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "u-boot-bounces@lists.denx.de",
        "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>"
    },
    "content": "utf8_get() - get next UTF-8 code point from buffer\nutf8_put() - write UTF-8 code point to buffer\nutf8_utf16_strnlen() - length of a utf-8 string after conversion to utf-16\nutf8_utf16_strncpy() - copy a utf-8 string to utf-16\nutf16_get() - get next UTF-16 code point from buffer\nutf16_put() - write UTF-16 code point to buffer\nutf16_utf8_strnlen() - length of a utf-16 string after conversion to utf-8\nutf16_utf8_strncpy() - copy a utf-16 string to utf-8\n\nSigned-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n---\n include/charset.h | 130 +++++++++++++++++++++++++\n lib/Makefile      |   4 +-\n lib/charset.c     | 243 +++++++++++++++++++++++++++++++++++++++++++++-\n 3 files changed, 373 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/include/charset.h b/include/charset.h\nindex 2307559890..81e31d1b26 100644\n--- a/include/charset.h\n+++ b/include/charset.h\n@@ -8,10 +8,140 @@\n #ifndef __CHARSET_H_\n #define __CHARSET_H_\n \n+#include <linux/kernel.h>\n #include <linux/types.h>\n \n #define MAX_UTF8_PER_UTF16 3\n \n+/**\n+ * utf8_get() - get next UTF-8 code point from buffer\n+ *\n+ * @src:\t\tpointer to current byte, updated to point to next byte\n+ * Return:\t\tcode point, or 0 for end of string, or -1 if no legal\n+ *\t\t\tcode point is found. In case of an error src points to\n+ *\t\t\tthe incorrect byte.\n+ */\n+s32 utf8_get(const char **src);\n+\n+/**\n+ * utf8_put() - write UTF-8 code point to buffer\n+ *\n+ * @code:\t\tcode point\n+ * @dst:\t\tpointer to destination buffer, updated to next position\n+ * Return:\t\t-1 if the input parameters are invalid\n+ */\n+int utf8_put(s32 code, char **dst);\n+\n+/**\n+ * utf8_utf16_strnlen() - length of a truncated utf-8 string after conversion\n+ *\t\t\t  to utf-16\n+ *\n+ * @src:\t\tutf-8 string\n+ * @count:\t\tmaximum number of code points to convert\n+ * Return:\t\tlength in bytes after conversion to utf-16 without the\n+ *\t\t\ttrailing \\0. If an invalid UTF-8 sequence is hit one\n+ *\t\t\tword will be reserved for a replacement character.\n+ */\n+size_t utf8_utf16_strnlen(const char *src, size_t count);\n+\n+/**\n+ * utf8_utf16_strlen() - length of a utf-8 string after conversion to utf-16\n+ *\n+ * @src:\t\tutf-8 string\n+ * Return:\t\tlength in bytes after conversion to utf-16 without the\n+ *\t\t\ttrailing \\0. -1 if the utf-8 string is not valid.\n+ */\n+#define utf8_utf16_strlen(a) utf8_utf16_strnlen((a), SIZE_MAX)\n+\n+/**\n+ * utf8_utf16_strncpy() - copy utf-8 string to utf-16 string\n+ *\n+ * @dst:\t\tdestination buffer\n+ * @src:\t\tsource buffer\n+ * @count:\t\tmaximum number of code points to copy\n+ * Return:\t\t-1 if the input parameters are invalid\n+ */\n+int utf8_utf16_strncpy(u16 **dst, const char *src, size_t count);\n+\n+/**\n+ * utf8_utf16_strcpy() - copy utf-8 string to utf-16 string\n+ *\n+ * @dst:\t\tdestination buffer\n+ * @src:\t\tsource buffer\n+ * Return:\t\t-1 if the input parameters are invalid\n+ */\n+#define utf8_utf16_strcpy(d, s) utf8_utf16_strncpy((d), (s), SIZE_MAX)\n+\n+/**\n+ * utf16_get() - get next UTF-16 code point from buffer\n+ *\n+ * @src:\t\tpointer to current word, updated to point to next word\n+ * Return:\t\tcode point, or 0 for end of string, or -1 if no legal\n+ *\t\t\tcode point is found. In case of an error src points to\n+ *\t\t\tthe incorrect word.\n+ */\n+s32 utf16_get(const u16 **src);\n+\n+/**\n+ * utf16_put() - write UTF-16 code point to buffer\n+ *\n+ * @code:\t\tcode point\n+ * @dst:\t\tpointer to destination buffer, updated to next position\n+ * Return:\t\t-1 if the input parameters are invalid\n+ */\n+int utf16_put(s32 code, u16 **dst);\n+\n+/**\n+ * utf16_strnlen() - length of a truncated utf-16 string\n+ *\n+ * @src:\t\tutf-16 string\n+ * @count:\t\tmaximum number of code points to convert\n+ * Return:\t\tlength in code points. If an invalid UTF-16 sequence is\n+ *\t\t\thit one position will be reserved for a replacement\n+ *\t\t\tcharacter.\n+ */\n+size_t utf16_strnlen(const u16 *src, size_t count);\n+\n+/**\n+ * utf16_utf8_strnlen() - length of a truncated utf-16 string after conversion\n+ *\t\t\t  to utf-8\n+ *\n+ * @src:\t\tutf-16 string\n+ * @count:\t\tmaximum number of code points to convert\n+ * Return:\t\tlength in bytes after conversion to utf-8 without the\n+ *\t\t\ttrailing \\0. If an invalid UTF-16 sequence is hit one\n+ *\t\t\tbyte will be reserved for a replacement character.\n+ */\n+size_t utf16_utf8_strnlen(const u16 *src, size_t count);\n+\n+/**\n+ * utf16_utf8_strlen() - length of a utf-16 string after conversion to utf-8\n+ *\n+ * @src:\t\tutf-16 string\n+ * Return:\t\tlength in bytes after conversion to utf-8 without the\n+ *\t\t\ttrailing \\0. -1 if the utf-16 string is not valid.\n+ */\n+#define utf16_utf8_strlen(a) utf16_utf8_strnlen((a), SIZE_MAX)\n+\n+/**\n+ * utf16_utf8_strncpy() - copy utf-16 string to utf-8 string\n+ *\n+ * @dst:\t\tdestination buffer\n+ * @src:\t\tsource buffer\n+ * @count:\t\tmaximum number of code points to copy\n+ * Return:\t\t-1 if the input parameters are invalid\n+ */\n+int utf16_utf8_strncpy(char **dst, const u16 *src, size_t count);\n+\n+/**\n+ * utf16_utf8_strcpy() - copy utf-16 string to utf-8 string\n+ *\n+ * @dst:\t\tdestination buffer\n+ * @src:\t\tsource buffer\n+ * Return:\t\t-1 if the input parameters are invalid\n+ */\n+#define utf16_utf8_strcpy(d, s) utf16_utf8_strncpy((d), (s), SIZE_MAX)\n+\n /**\n  * u16_strlen - count non-zero words\n  *\ndiff --git a/lib/Makefile b/lib/Makefile\nindex 2fd32798a0..f169644850 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -21,7 +21,9 @@ obj-$(CONFIG_OPTEE) += optee/\n obj-$(CONFIG_AES) += aes.o\n \n ifndef API_BUILD\n-obj-$(CONFIG_EFI_LOADER) += charset.o\n+ifneq ($(CONFIG_UT_UNICODE)$(CONFIG_EFI_LOADER),)\n+obj-y += charset.o\n+endif\n endif\n obj-$(CONFIG_USB_TTY) += circbuf.o\n obj-y += crc7.o\ndiff --git a/lib/charset.c b/lib/charset.c\nindex 8ff8d59957..0f4c6f26eb 100644\n--- a/lib/charset.c\n+++ b/lib/charset.c\n@@ -8,9 +8,246 @@\n #include <charset.h>\n #include <malloc.h>\n \n-/*\n- * utf8/utf16 conversion mostly lifted from grub\n- */\n+s32 utf8_get(const char **src)\n+{\n+\ts32 code = 0;\n+\tunsigned char c;\n+\n+\tif (!src || !*src)\n+\t\treturn -1;\n+\tif (!**src)\n+\t\treturn 0;\n+\tc = **src;\n+\tif (c >= 0x80) {\n+\t\t/*\n+\t\t * We do not expect a continuation byte (0x80 - 0xbf).\n+\t\t * 0x80 is coded as 0xc2 0x80, so we cannot have less then 0xc2\n+\t\t * here.\n+\t\t * The highest code point is 0x10ffff which is coded as\n+\t\t * 0xf4 0x8f 0xbf 0xbf. So we cannot have a byte above 0xf4.\n+\t\t */\n+\t\tif (c < 0xc2 || code > 0xf4)\n+\t\t\treturn -1;\n+\t\tif (c >= 0xe0) {\n+\t\t\tif (c >= 0xf0) {\n+\t\t\t\t/* 0xf0 - 0xf4 */\n+\t\t\t\tc &= 0x07;\n+\t\t\t\tcode = c << 18;\n+\t\t\t\t++*src;\n+\t\t\t\tc = **src;\n+\t\t\t\tif (c < 0x80 || c > 0xbf)\n+\t\t\t\t\treturn -1;\n+\t\t\t\tc &= 0x3f;\n+\t\t\t} else {\n+\t\t\t\t/* 0xe0 - 0xef */\n+\t\t\t\tc &= 0x0f;\n+\t\t\t}\n+\t\t\tcode += c << 12;\n+\t\t\tif ((code >= 0xD800 && code <= 0xDFFF) ||\n+\t\t\t    code >= 0x110000)\n+\t\t\t\treturn -1;\n+\t\t\t++*src;\n+\t\t\tc = **src;\n+\t\t\tif (c < 0x80 || c > 0xbf)\n+\t\t\t\treturn -1;\n+\t\t}\n+\t\t/* 0xc0 - 0xdf or continuation byte (0x80 - 0xbf) */\n+\t\tc &= 0x3f;\n+\t\tcode += c << 6;\n+\t\t++*src;\n+\t\tc = **src;\n+\t\tif (c < 0x80 || c > 0xbf)\n+\t\t\treturn -1;\n+\t\tc &= 0x3f;\n+\t}\n+\tcode += c;\n+\t++*src;\n+\treturn code;\n+}\n+\n+int utf8_put(s32 code, char **dst)\n+{\n+\tif (!dst || !*dst)\n+\t\treturn -1;\n+\tif ((code >= 0xD800 && code <= 0xDFFF) || code >= 0x110000)\n+\t\treturn -1;\n+\tif (code <= 0x007F) {\n+\t\t**dst = code;\n+\t} else {\n+\t\tif (code <= 0x07FF) {\n+\t\t\t**dst = code >> 6 | 0xC0;\n+\t\t} else {\n+\t\t\tif (code < 0x10000) {\n+\t\t\t\t**dst = code >> 12 | 0xE0;\n+\t\t\t} else {\n+\t\t\t\t**dst = code >> 18 | 0xF0;\n+\t\t\t\t++*dst;\n+\t\t\t\t**dst = (code >> 12 & 0x3F) | 0x80;\n+\t\t\t}\n+\t\t\t++*dst;\n+\t\t\t**dst = (code >> 6 & 0x3F) | 0x80;\n+\t\t}\n+\t\t++*dst;\n+\t\t**dst = (code & 0x3F) | 0x80;\n+\t}\n+\t++*dst;\n+\treturn 0;\n+}\n+\n+size_t utf8_utf16_strnlen(const char *src, size_t count)\n+{\n+\tsize_t len = 0;\n+\n+\tfor (; *src && count; --count)  {\n+\t\ts32 code = utf8_get(&src);\n+\n+\t\tif (!code)\n+\t\t\tbreak;\n+\t\tif (code < 0) {\n+\t\t\t/* Reserve space for a replacement character */\n+\t\t\tlen += 1;\n+\t\t\tif (*src)\n+\t\t\t\t++src;\n+\t\t} else if (code < 0x10000) {\n+\t\t\tlen += 1;\n+\t\t} else {\n+\t\t\tlen += 2;\n+\t\t}\n+\t}\n+\treturn len;\n+}\n+\n+int utf8_utf16_strncpy(u16 **dst, const char *src, size_t count)\n+{\n+\tif (!src || !dst || !*dst)\n+\t\treturn -1;\n+\n+\tfor (; count && *src; --count) {\n+\t\ts32 code = utf8_get(&src);\n+\n+\t\tif (code < 0) {\n+\t\t\tcode = '?';\n+\t\t\tif (*src)\n+\t\t\t\t++src;\n+\t\t}\n+\t\tutf16_put(code, dst);\n+\t}\n+\t**dst = 0;\n+\treturn 0;\n+}\n+\n+s32 utf16_get(const u16 **src)\n+{\n+\ts32 code, code2;\n+\n+\tif (!src || !*src)\n+\t\treturn -1;\n+\tif (!**src)\n+\t\treturn 0;\n+\tcode = **src;\n+\t++*src;\n+\tif (code >= 0xD800 && code <= 0xDBFF) {\n+\t\tif (!**src)\n+\t\t\treturn -1;\n+\t\tcode &= 0x3ff;\n+\t\tcode <<= 10;\n+\t\tcode += 0x10000;\n+\t\tcode2 = **src;\n+\t\tif (code2 <= 0xDC00 || code2 >= 0xDFFF)\n+\t\t\treturn -1;\n+\t\t++*src;\n+\t\tcode2 &= 0x3ff;\n+\t\tcode += code2;\n+\t}\n+\treturn code;\n+}\n+\n+int utf16_put(s32 code, u16 **dst)\n+{\n+\tif (!dst || !*dst)\n+\t\treturn -1;\n+\tif ((code >= 0xD800 && code <= 0xDFFF) || code >= 0x110000)\n+\t\treturn -1;\n+\tif (code < 0x10000) {\n+\t\t**dst = code;\n+\t} else {\n+\t\tcode -= 0x10000;\n+\t\t**dst = code >> 10 | 0xD800;\n+\t\t++*dst;\n+\t\t**dst = (code & 0x3ff) | 0xDC00;\n+\t}\n+\t++*dst;\n+\treturn 0;\n+}\n+\n+size_t utf16_strnlen(const u16 *src, size_t count)\n+{\n+\tsize_t len = 0;\n+\n+\tfor (; *src && count; --count)  {\n+\t\ts32 code = utf16_get(&src);\n+\n+\t\tif (!code)\n+\t\t\tbreak;\n+\t\tif (code < 0) {\n+\t\t\tif (*src)\n+\t\t\t\t++src;\n+\t\t}\n+\t\t/*\n+\t\t * In case of an illegal sequence still reserve space for a\n+\t\t * replacement character.\n+\t\t */\n+\t\t++len;\n+\t}\n+\treturn len;\n+}\n+\n+size_t utf16_utf8_strnlen(const u16 *src, size_t count)\n+{\n+\tsize_t len = 0;\n+\n+\tfor (; *src && count; --count)  {\n+\t\ts32 code = utf16_get(&src);\n+\n+\t\tif (!code)\n+\t\t\tbreak;\n+\t\tif (code < 0) {\n+\t\t\t/* Reserve space for a replacement character */\n+\t\t\tlen += 1;\n+\t\t\tif (*src)\n+\t\t\t\t++src;\n+\t\t} else if (code < 0x80) {\n+\t\t\tlen += 1;\n+\t\t} else if (code < 0x800) {\n+\t\t\tlen += 2;\n+\t\t} else if (code < 0x10000) {\n+\t\t\tlen += 3;\n+\t\t} else {\n+\t\t\tlen += 4;\n+\t\t}\n+\t}\n+\treturn len;\n+}\n+\n+int utf16_utf8_strncpy(char **dst, const u16 *src, size_t count)\n+{\n+\tif (!src || !dst || !*dst)\n+\t\treturn -1;\n+\n+\tfor (; count && *src; --count) {\n+\t\ts32 code = utf16_get(&src);\n+\n+\t\tif (code < 0) {\n+\t\t\tcode = '?';\n+\t\t\tif (*src)\n+\t\t\t\t++src;\n+\t\t}\n+\t\tutf8_put(code, dst);\n+\t}\n+\t**dst = 0;\n+\treturn 0;\n+}\n+\n \n size_t u16_strlen(const u16 *in)\n {\n",
    "prefixes": [
        "U-Boot",
        "03/15"
    ]
}