From ad5a96ab2daeeac53f0c924113f23dc931f965c5 Mon Sep 17 00:00:00 2001 From: rsun3 Date: Thu, 16 Apr 2009 08:46:28 +0000 Subject: Retire language conversion APIs from HII library class. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8104 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c | 182 +++++++++++++++++++++ .../Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf | 1 + 2 files changed, 183 insertions(+) (limited to 'EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk') diff --git a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c index 4ab74bad83..33c8510b8d 100644 --- a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c +++ b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c @@ -30,6 +30,7 @@ Module Name: #include #include #include +#include /// @@ -37,6 +38,187 @@ Module Name: /// #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 Iso639ToRfc3066ConversionTable[] = +"\ +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 ISO639-2 to RFC3066 and return the converted language. + Caller is responsible for freeing the allocated buffer. + + LanguageIso639 contain a single ISO639-2 code such as + "eng" or "fra". + + If LanguageIso639 is NULL, then ASSERT. + If LanguageRfc3066 is NULL, then ASSERT. + + @param LanguageIso639 ISO639-2 language code. + + @return the allocated buffer or NULL, if the language is not found. + +**/ +CHAR8* +EFIAPI +ConvertIso639LanguageToRfc3066Language ( + IN CONST CHAR8 *LanguageIso639 + ) +{ + UINTN Index; + CHAR8 *Rfc3066Language; + + for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) { + if (CompareMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3) == 0) { + Rfc3066Language = AllocateZeroPool (3); + if (Rfc3066Language != NULL) { + Rfc3066Language = CopyMem (Rfc3066Language, &Iso639ToRfc3066ConversionTable[Index + 3], 2); + } + return Rfc3066Language; + } + } + + return NULL; +} + /** Performs a case-insensitive comparison of two Null-terminated Unicode strings. diff --git a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf index 5e0266919d..be9db2887c 100644 --- a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf +++ b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf @@ -53,6 +53,7 @@ UefiLib MemoryAllocationLib HiiLib + BaseMemoryLib [Protocols] gEfiUnicodeCollation2ProtocolGuid -- cgit v1.2.3