diff options
author | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-05-08 01:51:35 +0000 |
---|---|---|
committer | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-05-08 01:51:35 +0000 |
commit | 7c9d25ae76f53b3cf20f615ae8902eef1648c5b5 (patch) | |
tree | e451ece2462021c7295a70cab5d189706d2cf2f4 /EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c | |
parent | e7796543162fefe5b34aab6336cb7a02945fccdf (diff) | |
download | edk2-platforms-7c9d25ae76f53b3cf20f615ae8902eef1648c5b5.tar.xz |
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/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c')
-rw-r--r-- | EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c | 297 |
1 files changed, 2 insertions, 295 deletions
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
|