mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-16 14:08:45 +00:00
lib: charset: upper/lower case conversion
Provide functions for upper and lower case conversion. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
5b2118a2ad
commit
b5130a8125
3 changed files with 73 additions and 0 deletions
|
@ -142,6 +142,22 @@ int utf16_utf8_strncpy(char **dst, const u16 *src, size_t count);
|
||||||
*/
|
*/
|
||||||
#define utf16_utf8_strcpy(d, s) utf16_utf8_strncpy((d), (s), SIZE_MAX)
|
#define utf16_utf8_strcpy(d, s) utf16_utf8_strncpy((d), (s), SIZE_MAX)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utf_to_lower() - convert a Unicode letter to lower case
|
||||||
|
*
|
||||||
|
* @code: letter to convert
|
||||||
|
* Return: lower case letter or unchanged letter
|
||||||
|
*/
|
||||||
|
s32 utf_to_lower(const s32 code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utf_to_upper() - convert a Unicode letter to upper case
|
||||||
|
*
|
||||||
|
* @code: letter to convert
|
||||||
|
* Return: upper case letter or unchanged letter
|
||||||
|
*/
|
||||||
|
s32 utf_to_upper(const s32 code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* u16_strlen - count non-zero words
|
* u16_strlen - count non-zero words
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,8 +6,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <charset.h>
|
#include <charset.h>
|
||||||
|
#include <capitalization.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
static struct capitalization_table capitalization_table[] =
|
||||||
|
#ifdef CONFIG_EFI_UNICODE_CAPITALIZATION
|
||||||
|
UNICODE_CAPITALIZATION_TABLE;
|
||||||
|
#elif CONFIG_FAT_DEFAULT_CODEPAGE == 1250
|
||||||
|
CP1250_CAPITALIZATION_TABLE;
|
||||||
|
#else
|
||||||
|
CP437_CAPITALIZATION_TABLE;
|
||||||
|
#endif
|
||||||
|
|
||||||
s32 utf8_get(const char **src)
|
s32 utf8_get(const char **src)
|
||||||
{
|
{
|
||||||
s32 code = 0;
|
s32 code = 0;
|
||||||
|
@ -241,6 +251,43 @@ int utf16_utf8_strncpy(char **dst, const u16 *src, size_t count)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 utf_to_lower(const s32 code)
|
||||||
|
{
|
||||||
|
struct capitalization_table *pos = capitalization_table;
|
||||||
|
s32 ret = code;
|
||||||
|
|
||||||
|
if (code <= 0x7f) {
|
||||||
|
if (code >= 'A' && code <= 'Z')
|
||||||
|
ret += 0x20;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
for (; pos->upper; ++pos) {
|
||||||
|
if (pos->upper == code) {
|
||||||
|
ret = pos->lower;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 utf_to_upper(const s32 code)
|
||||||
|
{
|
||||||
|
struct capitalization_table *pos = capitalization_table;
|
||||||
|
s32 ret = code;
|
||||||
|
|
||||||
|
if (code <= 0x7f) {
|
||||||
|
if (code >= 'a' && code <= 'z')
|
||||||
|
ret -= 0x20;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
for (; pos->lower; ++pos) {
|
||||||
|
if (pos->lower == code) {
|
||||||
|
ret = pos->upper;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
size_t u16_strlen(const u16 *in)
|
size_t u16_strlen(const u16 *in)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,16 @@ config EFI_LOADER
|
||||||
interfaces to a loaded EFI application, enabling it to reuse U-Boot's
|
interfaces to a loaded EFI application, enabling it to reuse U-Boot's
|
||||||
device drivers.
|
device drivers.
|
||||||
|
|
||||||
|
config EFI_UNICODE_CAPITALIZATION
|
||||||
|
bool "Support Unicode capitalization"
|
||||||
|
depends on EFI_LOADER
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
Select this option to enable correct handling of the capitalization of
|
||||||
|
Unicode codepoints in the range 0x0000-0xffff. If this option is not
|
||||||
|
set, only the the correct handling of the letters of the codepage
|
||||||
|
used by the FAT file system is ensured.
|
||||||
|
|
||||||
config EFI_LOADER_BOUNCE_BUFFER
|
config EFI_LOADER_BOUNCE_BUFFER
|
||||||
bool "EFI Applications use bounce buffers for DMA operations"
|
bool "EFI Applications use bounce buffers for DMA operations"
|
||||||
depends on EFI_LOADER && ARM64
|
depends on EFI_LOADER && ARM64
|
||||||
|
|
Loading…
Add table
Reference in a new issue