Refine language conversion in ECP. Create a new library LanguageLib providing functions for language conversion between ISO 639-2 and RFC 4646 styles. Update FrameworkHiiOnUefiHiiThunk, UcOnUc2Thunk and Uc2OnUcThunk modules to use this library.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8258 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
rsun3
2009-05-08 01:51:35 +00:00
parent e779654316
commit 7c9d25ae76
13 changed files with 686 additions and 736 deletions

View File

@@ -31,190 +31,7 @@ Module Name:
#include <Library/MemoryAllocationLib.h>
#include <Library/HiiLib.h>
#include <Library/BaseMemoryLib.h>
///
/// The size of a 3 character ISO639 language code.
///
#define ISO_639_2_ENTRY_SIZE 3
//
// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes
// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.
// The last 2 CHAR8 values are the ISO 639-1 code.
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 Iso639ToRfc4646ConversionTable[] =
"\
aaraa\
abkab\
afraf\
amham\
araar\
asmas\
aymay\
azeaz\
bakba\
belbe\
benbn\
bihbh\
bisbi\
bodbo\
brebr\
bulbg\
catca\
cescs\
corkw\
cosco\
cymcy\
danda\
deude\
dzodz\
ellel\
engen\
epoeo\
estet\
euseu\
faofo\
fasfa\
fijfj\
finfi\
frafr\
fryfy\
gaiga\
gdhgd\
glggl\
grngn\
gujgu\
hauha\
hebhe\
hinhi\
hrvhr\
hunhu\
hyehy\
ikuiu\
ileie\
inaia\
indid\
ipkik\
islis\
itait\
jawjw\
jpnja\
kalkl\
kankn\
kasks\
katka\
kazkk\
khmkm\
kinrw\
kirky\
korko\
kurku\
laolo\
latla\
lavlv\
linln\
litlt\
ltzlb\
malml\
marmr\
mkdmk\
mlgmg\
mltmt\
molmo\
monmn\
mrimi\
msams\
myamy\
nauna\
nepne\
nldnl\
norno\
ocioc\
ormom\
panpa\
polpl\
porpt\
pusps\
quequ\
rohrm\
ronro\
runrn\
rusru\
sagsg\
sansa\
sinsi\
slksk\
slvsl\
smise\
smosm\
snasn\
sndsd\
somso\
sotst\
spaes\
sqisq\
srpsr\
sswss\
sunsu\
swasw\
swesv\
tamta\
tattt\
telte\
tgktg\
tgltl\
thath\
tsnts\
tuktk\
twitw\
uigug\
ukruk\
urdur\
uzbuz\
vievi\
volvo\
wolwo\
xhoxh\
yidyi\
zhaza\
zhozh\
zulzu\
";
/**
Convert language code from RFC4646 to ISO639-2.
@param LanguageRfc4646 RFC4646 language code.
@param LanguageIso639 ISO639-2 language code.
@retval EFI_SUCCESS Language code converted.
@retval EFI_NOT_FOUND Language code not found.
**/
EFI_STATUS
EFIAPI
ConvertRfc4646LanguageToIso639Language (
IN CHAR8 *LanguageRfc4646,
OUT CHAR8 *LanguageIso639
)
{
UINTN Index;
if ((LanguageRfc4646[2] != '-') && (LanguageRfc4646[2] != 0)) {
CopyMem (LanguageIso639, LanguageRfc4646, 3);
return EFI_SUCCESS;
}
for (Index = 0; Iso639ToRfc4646ConversionTable[Index] != 0; Index += 5) {
if (CompareMem (LanguageRfc4646, &Iso639ToRfc4646ConversionTable[Index + 3], 2) == 0) {
CopyMem (LanguageIso639, &Iso639ToRfc4646ConversionTable[Index], 3);
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
#include <Library/LanguageLib.h>
/**
Performs a case-insensitive comparison of two Null-terminated Unicode
@@ -427,10 +244,9 @@ Uc2NotificationEvent (
//
// Fill in rest of private data structure
//
Private->UC.SupportedLanguages = AllocateZeroPool (ISO_639_2_ENTRY_SIZE + 1);
Status = ConvertRfc4646LanguageToIso639Language (Private->UC2->SupportedLanguages, Private->UC.SupportedLanguages);
Private->UC.SupportedLanguages = ConvertLanguagesRfc4646ToIso639 (Private->UC2->SupportedLanguages);
if (!EFI_ERROR (Status)) {
if (Private->UC.SupportedLanguages != NULL) {
//
// Install Firmware Volume Protocol onto same handle