summaryrefslogtreecommitdiffstats
path: root/EdkCompatibilityPkg
diff options
context:
space:
mode:
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-08 01:51:35 +0000
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-08 01:51:35 +0000
commit7c9d25ae76f53b3cf20f615ae8902eef1648c5b5 (patch)
treee451ece2462021c7295a70cab5d189706d2cf2f4 /EdkCompatibilityPkg
parente7796543162fefe5b34aab6336cb7a02945fccdf (diff)
downloadedk2-7c9d25ae76f53b3cf20f615ae8902eef1648c5b5.tar.gz
edk2-7c9d25ae76f53b3cf20f615ae8902eef1648c5b5.tar.bz2
edk2-7c9d25ae76f53b3cf20f615ae8902eef1648c5b5.zip
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
Diffstat (limited to 'EdkCompatibilityPkg')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf2
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c75
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h1
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c297
-rw-r--r--EdkCompatibilityPkg/Compatibility/Include/Library/LanguageLib.h116
-rw-r--r--EdkCompatibilityPkg/Compatibility/Library/LanguageLib.c499
-rw-r--r--EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf43
-rw-r--r--EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c190
-rw-r--r--EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf2
-rw-r--r--EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.c190
-rw-r--r--EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.inf2
-rw-r--r--EdkCompatibilityPkg/EdkCompatibilityPkg.dec4
-rw-r--r--EdkCompatibilityPkg/EdkCompatibilityPkg.dsc1
13 files changed, 686 insertions, 736 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf
index 2b037182eb..1c0c362161 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf
@@ -66,6 +66,7 @@
MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+ EdkCompatibilityPkg/EdkCompatibilityPkg.dec
[LibraryClasses]
UefiRuntimeServicesTableLib
@@ -79,6 +80,7 @@
PrintLib
UefiLib
PcdLib
+ LanguageLib
[Guids]
gEfiIfrTianoGuid
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c
index a25650d8d7..ec7159b60b 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c
@@ -305,65 +305,6 @@ HiiFindHandles (
return EFI_SUCCESS;
}
-EFI_STATUS
-LangCodes4646To639 (
- IN CHAR8 *LangCodes4646,
- IN CHAR8 **LangCodes639
- )
-{
- CHAR8 *AsciiLangCodes;
- CHAR8 *Lang;
- UINTN Index;
- UINTN Count;
- EFI_STATUS Status;
-
- ASSERT (LangCodes4646 != NULL);
- ASSERT (LangCodes639 != NULL);
-
- //
- // Allocate working buffer to contain substring of LangCodes4646.
- //
- Lang = AllocatePool (AsciiStrSize (LangCodes4646));
- if (Lang == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Count the number of RFC 4646 language codes.
- //
- Index = 0;
- AsciiLangCodes = LangCodes4646;
- while (AsciiStrLen (AsciiLangCodes) != 0) {
- GetNextLanguage (&AsciiLangCodes, Lang);
- Index++;
- }
-
- Count = Index;
-
- //
- //
- //
- *LangCodes639 = AllocateZeroPool (ISO_639_2_ENTRY_SIZE * Count + 1);
- if (*LangCodes639 == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- AsciiLangCodes = LangCodes4646;
-
- for (Index = 0; Index < Count; Index++) {
- GetNextLanguage (&AsciiLangCodes, Lang);
- Status = ConvertRfc4646LanguageToIso639Language (Lang, *LangCodes639 + Index * ISO_639_2_ENTRY_SIZE);
- ASSERT_EFI_ERROR (Status);
- }
-
- Status = EFI_SUCCESS;
-
-Done:
- FreePool (Lang);
- return Status;
-}
-
/**
Allows a program to determine the primary languages that are supported on a given handle.
@@ -409,10 +350,9 @@ HiiGetPrimaryLanguages (
return EFI_INVALID_PARAMETER;
}
-
- LangCodes639 = NULL;
- Status = LangCodes4646To639 (LangCodes4646, &LangCodes639);
- if (EFI_ERROR (Status)) {
+ LangCodes639 = ConvertLanguagesRfc4646ToIso639 (LangCodes4646);
+ if (LangCodes639 == NULL) {
+ Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -427,6 +367,7 @@ HiiGetPrimaryLanguages (
//
AsciiStrToUnicodeStr (LangCodes639, UnicodeLangCodes639);
*LanguageString = UnicodeLangCodes639;
+ Status = EFI_SUCCESS;
Done:
FreePool (LangCodes4646);
@@ -551,7 +492,7 @@ HiiGetSecondaryLanguages (
UnicodeStrToAsciiStr (PrimaryLanguage, PrimaryLang639);
- PrimaryLang4646 = ConvertIso639LanguageToRfc4646Language (PrimaryLang639);
+ PrimaryLang4646 = ConvertLanguagesIso639ToRfc4646 (PrimaryLang639);
ASSERT_EFI_ERROR (PrimaryLang4646 != NULL);
SecLangCodes4646 = HiiGetSupportedSecondaryLanguages (UefiHiiHandle, PrimaryLang4646);
@@ -561,8 +502,9 @@ HiiGetSecondaryLanguages (
goto Done;
}
- Status = LangCodes4646To639 (SecLangCodes4646, &SecLangCodes639);
- if (EFI_ERROR (Status)) {
+ SecLangCodes639 = ConvertLanguagesIso639ToRfc4646 (SecLangCodes4646);
+ if (SecLangCodes639 == NULL) {
+ Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -576,6 +518,7 @@ HiiGetSecondaryLanguages (
// The language returned is in RFC 4646 format.
//
*LanguageString = AsciiStrToUnicodeStr (SecLangCodes639, UnicodeSecLangCodes639);
+ Status = EFI_SUCCESS;
Done:
if (PrimaryLang639 != NULL) {
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h
index 1ae31b4e6f..9878df45de 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h
@@ -47,6 +47,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/HiiLib.h>
#include <Library/UefiLib.h>
#include <Library/PcdLib.h>
+#include <Library/LanguageLib.h>
#include <Guid/MdeModuleHii.h>
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
index daf652c1ab..d0b356be51 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
@@ -15,299 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
-typedef struct {
- CHAR8 *Iso639;
- CHAR8 *Rfc4646;
-} ISO639TORFC4646MAP;
-
-ISO639TORFC4646MAP Iso639ToRfc4646Map [] = {
- {"eng", "en-US"},
- {"fra", "fr-FR"},
-};
-
-//
-// 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\
-";
-
-CHAR8 *
-ConvertIso639ToRfc4646 (
- CHAR8 *Iso638Lang
- )
-{
- UINTN Index;
- CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];
-
- AsciiStrnCpy (AsciiLanguage, Iso638Lang, sizeof (AsciiLanguage));
- for (Index = 0; Index < ISO_639_2_ENTRY_SIZE + 1; Index ++) {
- if (AsciiLanguage [Index] == 0) {
- break;
- } else if (AsciiLanguage [Index] >= 'A' && AsciiLanguage [Index] <= 'Z') {
- AsciiLanguage [Index] = (CHAR8) (AsciiLanguage [Index] - 'A' + 'a');
- }
- }
-
- for (Index = 0; Index < sizeof (Iso639ToRfc4646Map) / sizeof (Iso639ToRfc4646Map[0]); Index++) {
- if (AsciiStrnCmp (AsciiLanguage, Iso639ToRfc4646Map[Index].Iso639, AsciiStrSize (AsciiLanguage)) == 0) {
- return Iso639ToRfc4646Map[Index].Rfc4646;
- }
- }
-
- return (CHAR8 *) NULL;
-}
-
-/**
- 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;
-}
-
-
-/**
- Convert language code from ISO639-2 to RFC4646 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 LanguageRfc4646 is NULL, then ASSERT.
-
- @param LanguageIso639 ISO639-2 language code.
-
- @return the allocated buffer or NULL, if the language is not found.
-
-**/
-CHAR8*
-EFIAPI
-ConvertIso639LanguageToRfc4646Language (
- IN CONST CHAR8 *LanguageIso639
- )
-{
- UINTN Index;
- CHAR8 *Rfc4646Language;
-
- for (Index = 0; Iso639ToRfc4646ConversionTable[Index] != 0; Index += 5) {
- if (CompareMem (LanguageIso639, &Iso639ToRfc4646ConversionTable[Index], 3) == 0) {
- Rfc4646Language = AllocateZeroPool (3);
- if (Rfc4646Language != NULL) {
- Rfc4646Language = CopyMem (Rfc4646Language, &Iso639ToRfc4646ConversionTable[Index + 3], 2);
- }
- return Rfc4646Language;
- }
- }
-
- return NULL;
-}
-
-/**
- Get next language from language code list (with separator ';').
-
- If LangCode is NULL, then ASSERT.
- If Lang is NULL, then ASSERT.
-
- @param LangCode On input: point to first language in the list. On
- output: point to next language in the list, or
- NULL if no more language in the list.
- @param Lang The first language in the list.
-
-**/
-VOID
-EFIAPI
-GetNextLanguage (
- IN OUT CHAR8 **LangCode,
- OUT CHAR8 *Lang
- )
-{
- UINTN Index;
- CHAR8 *StringPtr;
-
- ASSERT (LangCode != NULL);
- ASSERT (*LangCode != NULL);
- ASSERT (Lang != NULL);
-
- Index = 0;
- StringPtr = *LangCode;
- while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
- Index++;
- }
-
- CopyMem (Lang, StringPtr, Index);
- Lang[Index] = 0;
-
- if (StringPtr[Index] == ';') {
- Index++;
- }
- *LangCode = StringPtr + Index;
-}
-
/**
Test if all of the characters in a string have corresponding font characters.
@@ -468,7 +175,7 @@ HiiNewString (
ZeroMem (LanguageCopy, sizeof (LanguageCopy));
CopyMem (LanguageCopy, Language, ISO_639_2_ENTRY_SIZE * sizeof (CHAR16));
UnicodeStrToAsciiStr (LanguageCopy, AsciiLanguage);
- Rfc4646AsciiLanguage = ConvertIso639ToRfc4646 (AsciiLanguage);
+ Rfc4646AsciiLanguage = ConvertLanguagesIso639ToRfc4646 (AsciiLanguage);
ASSERT (Rfc4646AsciiLanguage != NULL);
}
@@ -614,7 +321,7 @@ HiiThunkGetString (
// Caller of Framework HII Interface uses the Language Identification String defined
// in Iso639. So map it to the Language Identifier defined in RFC4646.
//
- Rfc4646AsciiLanguage = ConvertIso639ToRfc4646 (Iso639AsciiLanguage);
+ Rfc4646AsciiLanguage = ConvertLanguagesIso639ToRfc4646 (Iso639AsciiLanguage);
//
// If Rfc4646AsciiLanguage is NULL, more language mapping must be added to
diff --git a/EdkCompatibilityPkg/Compatibility/Include/Library/LanguageLib.h b/EdkCompatibilityPkg/Compatibility/Include/Library/LanguageLib.h
new file mode 100644
index 0000000000..cc9a5d36ea
--- /dev/null
+++ b/EdkCompatibilityPkg/Compatibility/Include/Library/LanguageLib.h
@@ -0,0 +1,116 @@
+/** @file
+ Provides functions for language conversion between ISO 639-2 and RFC 4646 styles.
+
+Copyright (c) 2009, Intel Corporation<BR>
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __LANGUAGE_LIB__
+#define __LANGUAGE_LIB__
+
+/**
+ Convert an ISO 639-2 language code to a RFC 4646 language code.
+ If the ISO 639-2 language code has a corresponding ISO 639-1 code, then the ISO 639-1
+ code is returned. Else the original ISO 639-2 code is returned. The returned RFC 4646
+ language code is composed of only a primary language subtag.
+
+ If Iso639Language is NULL, then ASSERT.
+ If Rfc4646Language is NULL, then ASSERT.
+
+ @param[out] Rfc4646Language Pointers to a buffer large enough for an ASCII string
+ which reprsents a RFC 4646 language code containging only
+ either a ISO 639-1 or ISO 639-2 primary language subtag.
+ This string is Null-terminated.
+ @param[in] Iso639Language Pointer to a 3-letter ASCII string which represents
+ an ISO 639-2 language code. This string is not required
+ to be Null-terminated.
+
+ @retval TRUE The ISO 639-2 language code was converted to a ISO 639-1 code.
+ @retval FALSE The language code does not have corresponding ISO 639-1 code.
+
+**/
+BOOLEAN
+EFIAPI
+ConvertIso639ToRfc4646 (
+ OUT CHAR8 *Rfc4646Language,
+ IN CONST CHAR8 *Iso639Language
+ );
+
+/**
+ Convert a RFC 4646 language code to an ISO 639-2 language code. The primary language
+ subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code. If the primary
+ language subtag is an ISO 639-1 code, then it is converted to its corresponding ISO 639-2
+ code (T code if applies). Else the ISO 639-2 code is returned.
+
+ If Rfc4646Language is NULL, then ASSERT.
+ If Iso639Language is NULL, then ASSERT.
+
+ @param[out] Iso639Language Pointers to a buffer large enough for a 3-letter ASCII string
+ which reprsents an ISO 639-2 language code. The string is Null-terminated.
+ @param[in] Rfc4646Language Pointer to a RFC 4646 language code string. This string is terminated
+ by a NULL or a ';' character.
+
+ @retval TRUE Language code converted successfully.
+ @retval FALSE The RFC 4646 language code is invalid or unsupported.
+
+**/
+BOOLEAN
+EFIAPI
+ConvertRfc4646ToIso639 (
+ OUT CHAR8 *Iso639Language,
+ IN CONST CHAR8 *Rfc4646Language
+ );
+
+/**
+ Convert ISO 639-2 language codes to RFC 4646 codes and return the converted codes.
+ Caller is responsible for freeing the allocated buffer.
+
+ If Iso639Languages is NULL, then ASSERT.
+
+ @param[in] Iso639Languages Pointers to a Null-terminated ISO 639-2 language codes string containing
+ one or more ISO 639-2 3-letter language codes.
+
+ @retval NULL Invalid ISO 639-2 language code found.
+ @retval NULL Out of memory.
+ @retval !NULL Pointer to the allocate buffer containing the Null-terminated converted language codes string.
+ This string is composed of one or more RFC4646 language codes each of which has only
+ ISO 639-1 2-letter primary language subtag.
+
+**/
+CHAR8 *
+EFIAPI
+ConvertLanguagesIso639ToRfc4646 (
+ IN CONST CHAR8 *Iso639Languages
+ );
+
+/**
+ Convert RFC 4646 language codes to ISO 639-2 codes and return the converted codes.
+ The primary language subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code.
+ Caller is responsible for freeing the allocated buffer.
+
+ If Rfc4646Languages is NULL, then ASSERT.
+
+ @param[in] Rfc4646Languages Pointers to a Null-terminated RFC 4646 language codes string containing
+ one or more RFC 4646 language codes.
+
+ @retval NULL Invalid or unsupported RFC 4646 language code found.
+ @retval NULL Out of memory.
+ @retval !NULL Pointer to the allocate buffer containing the Null-terminated converted language codes string.
+ This string is composed of one or more ISO 639-2 language codes.
+
+**/
+CHAR8 *
+EFIAPI
+ConvertLanguagesRfc4646ToIso639 (
+ IN CONST CHAR8 *Rfc4646Languages
+ );
+
+
+#endif
diff --git a/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.c b/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.c
new file mode 100644
index 0000000000..9015865c2f
--- /dev/null
+++ b/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.c
@@ -0,0 +1,499 @@
+/** @file
+ Language Library implementation that provides functions for language conversion
+ between ISO 639-2 and RFC 4646 language codes.
+
+ Copyright (c) 2009, Intel Corporation<BR>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/LanguageLib.h>
+
+//
+// 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.
+//
+// ISO 639-2 B codes and deprecated ISO 639-1 codes are not supported.
+//
+// Commonly used language codes such as English and French are put in the front of the table for quick match.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mIso639ToRfc4646ConversionTable[] =
+"\
+engen\
+frafr\
+aaraa\
+abkab\
+aveae\
+afraf\
+akaak\
+amham\
+argan\
+araar\
+asmas\
+avaav\
+aymay\
+azeaz\
+bakba\
+belbe\
+bulbg\
+bihbh\
+bisbi\
+bambm\
+benbn\
+bodbo\
+brebr\
+bosbs\
+catca\
+chece\
+chach\
+cosco\
+crecr\
+cescs\
+chucu\
+chvcv\
+cymcy\
+danda\
+deude\
+divdv\
+dzodz\
+eweee\
+ellel\
+epoeo\
+spaes\
+estet\
+euseu\
+fasfa\
+fulff\
+finfi\
+fijfj\
+faofo\
+fryfy\
+glega\
+glagd\
+glggl\
+grngn\
+gujgu\
+glvgv\
+hauha\
+hebhe\
+hinhi\
+hmoho\
+hrvhr\
+hatht\
+hunhu\
+hyehy\
+herhz\
+inaia\
+indid\
+ileie\
+iboig\
+iiiii\
+ipkik\
+idoio\
+islis\
+itait\
+ikuiu\
+jpnja\
+javjv\
+katka\
+konkg\
+kikki\
+kuakj\
+kazkk\
+kalkl\
+khmkm\
+kankn\
+korko\
+kaukr\
+kasks\
+kurku\
+komkv\
+corkw\
+kirky\
+latla\
+ltzlb\
+luglg\
+limli\
+linln\
+laolo\
+litlt\
+lublu\
+lavlv\
+mlgmg\
+mahmh\
+mrimi\
+mkdmk\
+malml\
+monmn\
+marmr\
+msams\
+mltmt\
+myamy\
+nauna\
+nobnb\
+ndend\
+nepne\
+ndong\
+nldnl\
+nnonn\
+norno\
+nblnr\
+navnv\
+nyany\
+ocioc\
+ojioj\
+ormom\
+orior\
+ossos\
+panpa\
+plipi\
+polpl\
+pusps\
+porpt\
+quequ\
+rohrm\
+runrn\
+ronro\
+rusru\
+kinrw\
+sansa\
+srdsc\
+sndsd\
+smese\
+sagsg\
+sinsi\
+slksk\
+slvsl\
+smosm\
+snasn\
+somso\
+sqisq\
+srpsr\
+sswss\
+sotst\
+sunsu\
+swesv\
+swasw\
+tamta\
+telte\
+tgktg\
+thath\
+tirti\
+tuktk\
+tgltl\
+tsntn\
+tonto\
+turtr\
+tsots\
+tattt\
+twitw\
+tahty\
+uigug\
+ukruk\
+urdur\
+uzbuz\
+venve\
+vievi\
+volvo\
+wlnwa\
+wolwo\
+xhoxh\
+yidyi\
+yoryo\
+zhaza\
+zhozh\
+zulzu\
+";
+
+/**
+ Converts upper case ASCII characters in an ASCII string to lower case ASCII
+ characters in an ASCII string.
+
+ If a an ASCII character in Source is in the range 'A'..'Z', then it is converted
+ to an ASCII character in the range 'a'..'z' in Destination. Otherwise, no
+ conversion is performed. Length ASCII characters from Source are convertered and
+ stored in Destination.
+
+ @param Destination An ASCII string to store the results of the conversion.
+ @param Source The source ASCII string of the conversion.
+ @param Length The number of ASCII characters to convert.
+
+**/
+VOID
+EFIAPI
+InternalLanguageLibToLower (
+ OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source,
+ IN UINTN Length
+ )
+{
+ for (; Length > 0; Length--, Destination++, Source++) {
+ *Destination = (*Source >= 'A' && *Source <= 'Z') ? *Source + ('a' - 'A') : *Source;
+ }
+}
+
+/**
+ Convert an ISO 639-2 language code to a RFC 4646 language code.
+ If the ISO 639-2 language code has a corresponding ISO 639-1 code, then the ISO 639-1
+ code is returned. Else the original ISO 639-2 code is returned. The returned RFC 4646
+ language code is composed of only a primary language subtag.
+
+ If Iso639Language is NULL, then ASSERT.
+ If Rfc4646Language is NULL, then ASSERT.
+
+ @param[out] Rfc4646Language Pointers to a buffer large enough for an ASCII string
+ which reprsents a RFC 4646 language code containging only
+ either a ISO 639-1 or ISO 639-2 primary language subtag.
+ This string is Null-terminated.
+ @param[in] Iso639Language Pointer to a 3-letter ASCII string which represents
+ an ISO 639-2 language code. This string is not required
+ to be Null-terminated.
+
+ @retval TRUE The ISO 639-2 language code was converted to a ISO 639-1 code.
+ @retval FALSE The language code does not have corresponding ISO 639-1 code.
+
+**/
+BOOLEAN
+EFIAPI
+ConvertIso639ToRfc4646 (
+ OUT CHAR8 *Rfc4646Language,
+ IN CONST CHAR8 *Iso639Language
+ )
+{
+ CONST CHAR8 *Match;
+
+ ASSERT (Iso639Language != NULL);
+ ASSERT (Rfc4646Language != NULL);
+
+ //
+ // Convert first 3 characters of Iso639Language to lower case ASCII characters in Rfc4646Language
+ //
+ InternalLanguageLibToLower (Rfc4646Language, Iso639Language, 3);
+ Rfc4646Language[3] = '\0';
+
+ Match = mIso639ToRfc4646ConversionTable;
+ do {
+ Match = AsciiStrStr (Match, Rfc4646Language);
+ if (Match == NULL) {
+ return FALSE;
+ }
+ if (((Match - mIso639ToRfc4646ConversionTable) % 5) == 0) {
+ break;
+ }
+ ++Match;
+ } while (TRUE);
+ Rfc4646Language[0] = Match[3];
+ Rfc4646Language[1] = Match[4];
+ Rfc4646Language[2] = '\0';
+ return TRUE;
+}
+
+/**
+ Convert a RFC 4646 language code to an ISO 639-2 language code. The primary language
+ subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code. If the primary
+ language subtag is an ISO 639-1 code, then it is converted to its corresponding ISO 639-2
+ code (T code if applies). Else the ISO 639-2 code is returned.
+
+ If Rfc4646Language is NULL, then ASSERT.
+ If Iso639Language is NULL, then ASSERT.
+
+ @param[out] Iso639Language Pointers to a buffer large enough for a 3-letter ASCII string
+ which reprsents an ISO 639-2 language code. The string is Null-terminated.
+ @param[in] Rfc4646Language Pointer to a RFC 4646 language code string. This string is terminated
+ by a NULL or a ';' character.
+
+ @retval TRUE Language code converted successfully.
+ @retval FALSE The RFC 4646 language code is invalid or unsupported.
+
+**/
+BOOLEAN
+EFIAPI
+ConvertRfc4646ToIso639 (
+ OUT CHAR8 *Iso639Language,
+ IN CONST CHAR8 *Rfc4646Language
+ )
+{
+ CONST CHAR8 *Match;
+
+ ASSERT (Rfc4646Language != NULL);
+ ASSERT (Iso639Language != NULL);
+
+ //
+ // RFC 4646 language code check before determining
+ // if the primary language subtag is ISO 639-1 or 639-2 code
+ //
+ if (Rfc4646Language[0] == '\0' || Rfc4646Language[1] == '\0') {
+ return FALSE;
+ }
+
+ //
+ // Check if the primary language subtag is ISO 639-1 code
+ //
+ if (Rfc4646Language[2] == ';' || Rfc4646Language[2] == '-' || Rfc4646Language[2] == '\0') {
+ //
+ // Convert first 2 characters of Rfc4646Language to lower case ASCII characters in Iso639Language
+ //
+ InternalLanguageLibToLower (Iso639Language, Rfc4646Language, 2);
+ //
+ // Convert ISO 639-1 code to ISO 639-2 code
+ //
+ Iso639Language[2] = '\0';
+ Match = mIso639ToRfc4646ConversionTable;
+ do {
+ Match = AsciiStrStr (Match, Iso639Language);
+ if (Match == NULL) {
+ return FALSE;
+ }
+ if (((Match - mIso639ToRfc4646ConversionTable) % 5) == 3) {
+ break;
+ }
+ ++Match;
+ } while (TRUE);
+ Rfc4646Language = Match - 3;
+ } else if (!(Rfc4646Language[3] == ';' || Rfc4646Language[3] == '-' || Rfc4646Language[3] == '\0')) {
+ return FALSE;
+ }
+ Iso639Language[0] = Rfc4646Language[0];
+ Iso639Language[1] = Rfc4646Language[1];
+ Iso639Language[2] = Rfc4646Language[2];
+ Iso639Language[3] = '\0';
+ return TRUE;
+}
+
+/**
+ Convert ISO 639-2 language codes to RFC 4646 codes and return the converted codes.
+ Caller is responsible for freeing the allocated buffer.
+
+ If Iso639Languages is NULL, then ASSERT.
+
+ @param[in] Iso639Languages Pointers to a Null-terminated ISO 639-2 language codes string containing
+ one or more ISO 639-2 3-letter language codes.
+
+ @retval NULL Invalid ISO 639-2 language code found.
+ @retval NULL Out of memory.
+ @retval !NULL Pointer to the allocate buffer containing the Null-terminated converted language codes string.
+ This string is composed of one or more RFC4646 language codes each of which has only
+ ISO 639-1 2-letter primary language subtag.
+
+**/
+CHAR8 *
+EFIAPI
+ConvertLanguagesIso639ToRfc4646 (
+ IN CONST CHAR8 *Iso639Languages
+ )
+{
+ UINTN Length;
+ UINTN Iso639Index;
+ UINTN Rfc4646Index;
+ CHAR8 *Rfc4646Languages;
+
+ ASSERT (Iso639Languages != NULL);
+
+ //
+ // The length of ISO 639-2 lanugage codes string must be multiple of 3
+ //
+ Length = AsciiStrLen (Iso639Languages);
+ if (Length % 3) {
+ return NULL;
+ }
+
+ //
+ // Allocate buffer for RFC 4646 language codes string
+ //
+ Rfc4646Languages = AllocatePool (Length + (Length / 3));
+ if (Rfc4646Languages == NULL) {
+ return NULL;
+ }
+
+ for (Iso639Index = 0, Rfc4646Index = 0; Iso639Languages[Iso639Index] != '\0'; Iso639Index += 3) {
+ if (ConvertIso639ToRfc4646 (&Rfc4646Languages[Rfc4646Index], &Iso639Languages[Iso639Index])) {
+ Rfc4646Index += 2;
+ } else {
+ Rfc4646Index += 3;
+ }
+ Rfc4646Languages[Rfc4646Index++] = ';';
+ }
+ Rfc4646Languages[Rfc4646Index - 1] = '\0';
+ return Rfc4646Languages;
+}
+
+/**
+ Convert RFC 4646 language codes to ISO 639-2 codes and return the converted codes.
+ The primary language subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code.
+ Caller is responsible for freeing the allocated buffer.
+
+ If Rfc4646Languages is NULL, then ASSERT.
+
+ @param[in] Rfc4646Languages Pointers to a Null-terminated RFC 4646 language codes string containing
+ one or more RFC 4646 language codes.
+
+ @retval NULL Invalid or unsupported RFC 4646 language code found.
+ @retval NULL Out of memory.
+ @retval !NULL Pointer to the allocate buffer containing the Null-terminated converted language codes string.
+ This string is composed of one or more ISO 639-2 language codes.
+
+**/
+CHAR8 *
+EFIAPI
+ConvertLanguagesRfc4646ToIso639 (
+ IN CONST CHAR8 *Rfc4646Languages
+ )
+{
+ UINTN NumLanguages;
+ UINTN Iso639Index;
+ UINTN Rfc4646Index;
+ CHAR8 *Iso639Languages;
+
+ ASSERT (Rfc4646Languages != NULL);
+
+ //
+ // Determine the number of languages in the RFC 4646 language codes string
+ //
+ for (Rfc4646Index = 0, NumLanguages = 1; Rfc4646Languages[Rfc4646Index] != '\0'; Rfc4646Index++) {
+ if (Rfc4646Languages[Rfc4646Index] == ';') {
+ NumLanguages++;
+ }
+ }
+
+ //
+ // Allocate buffer for ISO 639-2 language codes string
+ //
+ Iso639Languages = AllocateZeroPool (NumLanguages * 3 + 1);
+ if (Iso639Languages == NULL) {
+ return NULL;
+ }
+
+ //
+ // Do the conversion for each RFC 4646 language code
+ //
+ for (Rfc4646Index = 0, Iso639Index = 0; Rfc4646Languages[Rfc4646Index] != '\0';) {
+ if (ConvertRfc4646ToIso639 (&Iso639Languages[Iso639Index], &Rfc4646Languages[Rfc4646Index])) {
+ Iso639Index += 3;
+ } else {
+ FreePool (Iso639Languages);
+ return NULL;
+ }
+ //
+ // Locate next language code
+ //
+ while (Rfc4646Languages[Rfc4646Index] != ';' && Rfc4646Languages[Rfc4646Index] != '\0') {
+ Rfc4646Index++;
+ }
+ if (Rfc4646Languages[Rfc4646Index] == ';') {
+ Rfc4646Index++;
+ }
+ }
+ Iso639Languages[Iso639Index] = '\0';
+ return Iso639Languages;
+}
+
diff --git a/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf b/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf
new file mode 100644
index 0000000000..1b4aed2777
--- /dev/null
+++ b/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf
@@ -0,0 +1,43 @@
+#/** @file
+# Instance of Language Library.
+#
+# The Language Library implementation that provides functions for language conversion
+# between ISO 639-2 and RFC 4646 language codes.
+#
+# Copyright (c) 2009, Intel Corporation
+#
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = LanguageLib
+ FILE_GUID = 283cad13-a151-4d55-be2d-96ea57392a82
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = LanguageLib|DXE_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources.common]
+ LanguageLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ EdkCompatibilityPkg/EdkCompatibilityPkg.dec
+
+[LibraryClasses]
+ MemoryAllocationLib
+ BaseLib
+ DebugLib
+
diff --git a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c
index c24bf8d009..31aba70a1d 100644
--- a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c
+++ b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c
@@ -31,193 +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 ISO639-2 to RFC4646 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 LanguageRfc4646 is NULL, then ASSERT.
-
- @param LanguageIso639 ISO639-2 language code.
-
- @return the allocated buffer or NULL, if the language is not found.
-
-**/
-CHAR8*
-EFIAPI
-ConvertIso639LanguageToRfc4646Language (
- IN CONST CHAR8 *LanguageIso639
- )
-{
- UINTN Index;
- CHAR8 *Rfc4646Language;
-
- for (Index = 0; Iso639ToRfc4646ConversionTable[Index] != 0; Index += 5) {
- if (CompareMem (LanguageIso639, &Iso639ToRfc4646ConversionTable[Index], 3) == 0) {
- Rfc4646Language = AllocateZeroPool (3);
- if (Rfc4646Language != NULL) {
- Rfc4646Language = CopyMem (Rfc4646Language, &Iso639ToRfc4646ConversionTable[Index + 3], 2);
- }
- return Rfc4646Language;
- }
- }
-
- return NULL;
-}
+#include <Library/LanguageLib.h>
/**
Performs a case-insensitive comparison of two Null-terminated Unicode
@@ -430,7 +244,7 @@ UcNotificationEvent (
//
// Fill in rest of private data structure
//
- Private->UC2.SupportedLanguages = ConvertIso639LanguageToRfc4646Language (Private->UC->SupportedLanguages);
+ Private->UC2.SupportedLanguages = ConvertLanguagesIso639ToRfc4646 (Private->UC->SupportedLanguages);
if (Private->UC2.SupportedLanguages != NULL) {
//
diff --git a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf
index be9db2887c..6c51afb8fb 100644
--- a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf
+++ b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.inf
@@ -44,6 +44,7 @@
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
+ EdkCompatibilityPkg/EdkCompatibilityPkg.dec
[LibraryClasses]
UefiDriverEntryPoint
@@ -54,6 +55,7 @@
MemoryAllocationLib
HiiLib
BaseMemoryLib
+ LanguageLib
[Protocols]
gEfiUnicodeCollation2ProtocolGuid
diff --git a/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.c b/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.c
index 094c36652a..bba93bdaaf 100644
--- a/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.c
+++ b/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.c
@@ -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
diff --git a/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.inf b/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.inf
index 600a0e6d84..1c776ce9bb 100644
--- a/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.inf
+++ b/EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.inf
@@ -44,6 +44,7 @@
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
+ EdkCompatibilityPkg/EdkCompatibilityPkg.dec
[LibraryClasses]
UefiDriverEntryPoint
@@ -54,6 +55,7 @@
MemoryAllocationLib
HiiLib
BaseMemoryLib
+ LanguageLib
[Protocols]
gEfiUnicodeCollation2ProtocolGuid
diff --git a/EdkCompatibilityPkg/EdkCompatibilityPkg.dec b/EdkCompatibilityPkg/EdkCompatibilityPkg.dec
index 03aeacb96a..2b57da8ec9 100644
--- a/EdkCompatibilityPkg/EdkCompatibilityPkg.dec
+++ b/EdkCompatibilityPkg/EdkCompatibilityPkg.dec
@@ -47,6 +47,10 @@
#
################################################################################
[LibraryClasses.common]
+ ## @libraryclass Provides functions for language conversion between
+ # ISO 639-2 and RFC 4646 styles.
+ ##
+ LanguageLib|Compatibility/Include/Library/LanguageLib.h
[Ppis.common]
gEcpPeiPciCfgPpiGuid = { 0xb0ee53d4, 0xa049, 0x4a79, { 0xb2, 0xff, 0x19, 0xd9, 0xfa, 0xef, 0xaa, 0x94 }}
diff --git a/EdkCompatibilityPkg/EdkCompatibilityPkg.dsc b/EdkCompatibilityPkg/EdkCompatibilityPkg.dsc
index 3cdbba59e1..9830f4f0dc 100644
--- a/EdkCompatibilityPkg/EdkCompatibilityPkg.dsc
+++ b/EdkCompatibilityPkg/EdkCompatibilityPkg.dsc
@@ -61,6 +61,7 @@ define GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+ LanguageLib|EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf
[LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf