]> git.dujemihanovic.xyz Git - u-boot.git/commit
efi_loader: MAX_UTF8_PER_UTF16 = 3
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 9 Oct 2017 19:09:05 +0000 (21:09 +0200)
committerAlexander Graf <agraf@suse.de>
Tue, 10 Oct 2017 08:01:27 +0000 (10:01 +0200)
commit984f251feeb932cfe551cbd62c5f7f5e073b6cc3
treee89009a68b9cfde6ac80bf4042d221807bab5c1f
parent16a73b249d138fedeb188710533902ed7aac1ddc
efi_loader: MAX_UTF8_PER_UTF16 = 3

The constant MAX_UTF8_PER_UTF16 is used to calculate
required memory when converting from UTF-16 to UTF-8.
If this constant is too big we waste memory.

A code point encoded by one UTF-16 symbol is converted to a
maximum of three UTF-8 symbols, e.g.

0xffff could be encoded as 0xef 0xbf 0xbf.
The first byte carries four bits, the second and third byte
carry six bits each.

A code point encoded by two UTF-16 symbols is converted to four
UTF-8 symbols.

So in this case we need a maximum of two UTF-8 symbols per
UTF-16 symbol.

As the overall maximum is three UTF-8 symobls per UTF-16 symbol
we need MAX_UTF8_PER_UTF16 = 3.

Fixes: 78178bb0c9d lib: add some utf16 handling helpers
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
include/charset.h