]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add directory for the new added Language Library.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 1 Jun 2009 06:46:03 +0000 (06:46 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 1 Jun 2009 06:46:03 +0000 (06:46 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8417 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Compatibility/Library/LanguageLib.c [deleted file]
EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf [deleted file]
EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/EdkCompatibilityPkg.dsc

diff --git a/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.c b/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.c
deleted file mode 100644 (file)
index 0595db7..0000000
+++ /dev/null
@@ -1,501 +0,0 @@
-/** @file\r
-  Language Library implementation that provides functions for language conversion\r
-  between ISO 639-2 and RFC 4646 language codes.\r
-\r
-  Copyright (c) 2009, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Library/LanguageLib.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-//\r
-// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes\r
-// Each entry is 5 CHAR8 values long.  The first 3 CHAR8 values are the ISO 639-2 code.\r
-// The last 2 CHAR8 values are the ISO 639-1 code.\r
-//\r
-// ISO 639-2 B codes and deprecated ISO 639-1 codes are not supported.\r
-//\r
-// Commonly used language codes such as English and French are put in the front of the table for quick match.\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mIso639ToRfc4646ConversionTable[] =\r
-"\\r
-engen\\r
-frafr\\r
-aaraa\\r
-abkab\\r
-aveae\\r
-afraf\\r
-akaak\\r
-amham\\r
-argan\\r
-araar\\r
-asmas\\r
-avaav\\r
-aymay\\r
-azeaz\\r
-bakba\\r
-belbe\\r
-bulbg\\r
-bihbh\\r
-bisbi\\r
-bambm\\r
-benbn\\r
-bodbo\\r
-brebr\\r
-bosbs\\r
-catca\\r
-chece\\r
-chach\\r
-cosco\\r
-crecr\\r
-cescs\\r
-chucu\\r
-chvcv\\r
-cymcy\\r
-danda\\r
-deude\\r
-divdv\\r
-dzodz\\r
-eweee\\r
-ellel\\r
-epoeo\\r
-spaes\\r
-estet\\r
-euseu\\r
-fasfa\\r
-fulff\\r
-finfi\\r
-fijfj\\r
-faofo\\r
-fryfy\\r
-glega\\r
-glagd\\r
-glggl\\r
-grngn\\r
-gujgu\\r
-glvgv\\r
-hauha\\r
-hebhe\\r
-hinhi\\r
-hmoho\\r
-hrvhr\\r
-hatht\\r
-hunhu\\r
-hyehy\\r
-herhz\\r
-inaia\\r
-indid\\r
-ileie\\r
-iboig\\r
-iiiii\\r
-ipkik\\r
-idoio\\r
-islis\\r
-itait\\r
-ikuiu\\r
-jpnja\\r
-javjv\\r
-katka\\r
-konkg\\r
-kikki\\r
-kuakj\\r
-kazkk\\r
-kalkl\\r
-khmkm\\r
-kankn\\r
-korko\\r
-kaukr\\r
-kasks\\r
-kurku\\r
-komkv\\r
-corkw\\r
-kirky\\r
-latla\\r
-ltzlb\\r
-luglg\\r
-limli\\r
-linln\\r
-laolo\\r
-litlt\\r
-lublu\\r
-lavlv\\r
-mlgmg\\r
-mahmh\\r
-mrimi\\r
-mkdmk\\r
-malml\\r
-monmn\\r
-marmr\\r
-msams\\r
-mltmt\\r
-myamy\\r
-nauna\\r
-nobnb\\r
-ndend\\r
-nepne\\r
-ndong\\r
-nldnl\\r
-nnonn\\r
-norno\\r
-nblnr\\r
-navnv\\r
-nyany\\r
-ocioc\\r
-ojioj\\r
-ormom\\r
-orior\\r
-ossos\\r
-panpa\\r
-plipi\\r
-polpl\\r
-pusps\\r
-porpt\\r
-quequ\\r
-rohrm\\r
-runrn\\r
-ronro\\r
-rusru\\r
-kinrw\\r
-sansa\\r
-srdsc\\r
-sndsd\\r
-smese\\r
-sagsg\\r
-sinsi\\r
-slksk\\r
-slvsl\\r
-smosm\\r
-snasn\\r
-somso\\r
-sqisq\\r
-srpsr\\r
-sswss\\r
-sotst\\r
-sunsu\\r
-swesv\\r
-swasw\\r
-tamta\\r
-telte\\r
-tgktg\\r
-thath\\r
-tirti\\r
-tuktk\\r
-tgltl\\r
-tsntn\\r
-tonto\\r
-turtr\\r
-tsots\\r
-tattt\\r
-twitw\\r
-tahty\\r
-uigug\\r
-ukruk\\r
-urdur\\r
-uzbuz\\r
-venve\\r
-vievi\\r
-volvo\\r
-wlnwa\\r
-wolwo\\r
-xhoxh\\r
-yidyi\\r
-yoryo\\r
-zhaza\\r
-zhozh\\r
-zulzu\\r
-";\r
-\r
-/**\r
-  Converts upper case ASCII characters in an ASCII string to lower case ASCII \r
-  characters in an ASCII string.\r
-\r
-  If a an ASCII character in Source is in the range 'A'..'Z', then it is converted \r
-  to an ASCII character in the range 'a'..'z' in Destination.  Otherwise, no \r
-  conversion is performed.  Length ASCII characters from Source are convertered and\r
-  stored in Destination.\r
-\r
-  @param  Destination  An ASCII string to store the results of the conversion.\r
-  @param  Source       The source ASCII string of the conversion.\r
-  @param  Length       The number of ASCII characters to convert.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-InternalLanguageLibToLower (\r
-  OUT CHAR8        *Destination,\r
-  IN  CONST CHAR8  *Source,\r
-  IN  UINTN        Length\r
-  )\r
-{\r
-  for (; Length > 0; Length--, Destination++, Source++) {\r
-    *Destination = (CHAR8)((*Source >= 'A' && *Source <= 'Z') ? *Source + ('a' - 'A') : *Source);\r
-  }\r
-}\r
-\r
-/**\r
-  Convert an ISO 639-2 language code to a RFC 4646 language code.\r
-  If the ISO 639-2 language code has a corresponding ISO 639-1 code, then the ISO 639-1\r
-  code is returned. Else the original ISO 639-2 code is returned. The returned RFC 4646\r
-  language code is composed of only a primary language subtag.\r
-\r
-  If Iso639Language is NULL, then ASSERT.\r
-  If Rfc4646Language is NULL, then ASSERT.\r
-\r
-  @param[out] Rfc4646Language  Pointers to a buffer large enough for an ASCII string\r
-                               which reprsents a RFC 4646 language code containging only\r
-                               either a ISO 639-1 or ISO 639-2 primary language subtag.\r
-                               This string is Null-terminated.\r
-  @param[in]  Iso639Language   Pointer to a 3-letter ASCII string which represents\r
-                               an ISO 639-2 language code. This string is not required\r
-                               to be Null-terminated.\r
-\r
-  @retval TRUE                 The ISO 639-2 language code was converted to a ISO 639-1 code.\r
-  @retval FALSE                The language code does not have corresponding ISO 639-1 code.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ConvertIso639ToRfc4646 (\r
-  OUT CHAR8        *Rfc4646Language,\r
-  IN  CONST CHAR8  *Iso639Language\r
-  )\r
-{\r
-  CONST CHAR8  *Match;\r
-  \r
-  ASSERT (Iso639Language != NULL);\r
-  ASSERT (Rfc4646Language != NULL);\r
-\r
-  //\r
-  // Convert first 3 characters of Iso639Language to lower case ASCII characters in Rfc4646Language\r
-  //\r
-  InternalLanguageLibToLower (Rfc4646Language, Iso639Language, 3);\r
-  Rfc4646Language[3] = '\0';\r
-\r
-  Match = mIso639ToRfc4646ConversionTable;\r
-  do {\r
-    Match = AsciiStrStr (Match, Rfc4646Language);\r
-    if (Match == NULL) {\r
-      return FALSE;\r
-    }\r
-    if (((Match - mIso639ToRfc4646ConversionTable) % 5) == 0) {\r
-      break;\r
-    }\r
-    ++Match;\r
-  } while (TRUE);\r
-  Rfc4646Language[0] = Match[3];\r
-  Rfc4646Language[1] = Match[4];\r
-  Rfc4646Language[2] = '\0';\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Convert a RFC 4646 language code to an ISO 639-2 language code. The primary language\r
-  subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code. If the primary\r
-  language subtag is an ISO 639-1 code, then it is converted to its corresponding ISO 639-2\r
-  code (T code if applies). Else the ISO 639-2 code is returned.\r
-\r
-  If Rfc4646Language is NULL, then ASSERT.\r
-  If Iso639Language is NULL, then ASSERT.\r
-\r
-  @param[out] Iso639Language   Pointers to a buffer large enough for a 3-letter ASCII string\r
-                               which reprsents an ISO 639-2 language code. The string is Null-terminated.\r
-  @param[in]  Rfc4646Language  Pointer to a RFC 4646 language code string. This string is terminated\r
-                               by a NULL or a ';' character.\r
-\r
-  @retval TRUE                 Language code converted successfully.\r
-  @retval FALSE                The RFC 4646 language code is invalid or unsupported.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ConvertRfc4646ToIso639 (\r
-  OUT CHAR8        *Iso639Language,\r
-  IN  CONST CHAR8  *Rfc4646Language\r
-  )\r
-{\r
-  CONST CHAR8 *Match;\r
-  \r
-  ASSERT (Rfc4646Language != NULL);\r
-  ASSERT (Iso639Language != NULL);\r
-\r
-  //\r
-  // RFC 4646 language code check before determining \r
-  // if the primary language subtag is ISO 639-1 or 639-2 code\r
-  //\r
-  if (Rfc4646Language[0] == '\0' || Rfc4646Language[1] == '\0') {\r
-    return FALSE;\r
-  }\r
-  \r
-  //\r
-  // Check if the primary language subtag is ISO 639-1 code\r
-  //\r
-  if (Rfc4646Language[2] == ';' || Rfc4646Language[2] == '-' || Rfc4646Language[2] == '\0') {\r
-    //\r
-    // Convert first 2 characters of Rfc4646Language to lower case ASCII characters in Iso639Language\r
-    //\r
-    InternalLanguageLibToLower (Iso639Language, Rfc4646Language, 2);\r
-    //\r
-    // Convert ISO 639-1 code to ISO 639-2 code\r
-    //\r
-    Iso639Language[2] = '\0';\r
-    Match = mIso639ToRfc4646ConversionTable;\r
-    do {\r
-      Match = AsciiStrStr (Match, Iso639Language);\r
-      if (Match == NULL) {\r
-        return FALSE;\r
-      }\r
-      if (((Match - mIso639ToRfc4646ConversionTable) % 5) == 3) {\r
-        break;\r
-      }\r
-      ++Match;\r
-    } while (TRUE);\r
-    Rfc4646Language = Match - 3;\r
-  } else if (!(Rfc4646Language[3] == ';' || Rfc4646Language[3] == '-' || Rfc4646Language[3] == '\0')) {\r
-    return FALSE;\r
-  }\r
-  Iso639Language[0] = Rfc4646Language[0];\r
-  Iso639Language[1] = Rfc4646Language[1];\r
-  Iso639Language[2] = Rfc4646Language[2];\r
-  Iso639Language[3] = '\0';\r
-  return TRUE;  \r
-}\r
-\r
-/**\r
-  Convert ISO 639-2 language codes to RFC 4646 codes and return the converted codes.\r
-  Caller is responsible for freeing the allocated buffer.\r
-\r
-  If Iso639Languages is NULL, then ASSERT.\r
-\r
-  @param[in] Iso639Languages  Pointers to a Null-terminated ISO 639-2 language codes string containing\r
-                              one or more ISO 639-2 3-letter language codes.\r
-  \r
-  @retval NULL                Invalid ISO 639-2 language code found.\r
-  @retval NULL                Out of memory.\r
-  @retval !NULL               Pointer to the allocate buffer containing the Null-terminated converted language codes string.\r
-                              This string is composed of one or more RFC4646 language codes each of which has only\r
-                              ISO 639-1 2-letter primary language subtag.\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-ConvertLanguagesIso639ToRfc4646 (\r
-  IN CONST CHAR8  *Iso639Languages\r
-  )\r
-{\r
-  UINTN  Length;\r
-  UINTN  Iso639Index;\r
-  UINTN  Rfc4646Index;\r
-  CHAR8  *Rfc4646Languages;\r
-  \r
-  ASSERT (Iso639Languages != NULL);\r
-  \r
-  //\r
-  // The length of ISO 639-2 lanugage codes string must be multiple of 3\r
-  //\r
-  Length = AsciiStrLen (Iso639Languages);\r
-  if (Length % 3) {\r
-    return NULL;\r
-  }\r
-  \r
-  //\r
-  // Allocate buffer for RFC 4646 language codes string\r
-  //\r
-  Rfc4646Languages = AllocatePool (Length + (Length / 3));\r
-  if (Rfc4646Languages == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  for (Iso639Index = 0, Rfc4646Index = 0; Iso639Languages[Iso639Index] != '\0'; Iso639Index += 3) {\r
-    if (ConvertIso639ToRfc4646 (&Rfc4646Languages[Rfc4646Index], &Iso639Languages[Iso639Index])) {\r
-      Rfc4646Index += 2;\r
-    } else {\r
-      Rfc4646Index += 3;\r
-    }\r
-    Rfc4646Languages[Rfc4646Index++] = ';';\r
-  }\r
-  Rfc4646Languages[Rfc4646Index - 1] = '\0';\r
-  return Rfc4646Languages;\r
-}\r
-\r
-/**\r
-  Convert RFC 4646 language codes to ISO 639-2 codes and return the converted codes.\r
-  The primary language subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code.\r
-  Caller is responsible for freeing the allocated buffer.\r
-\r
-  If Rfc4646Languages is NULL, then ASSERT.\r
-\r
-  @param[in] Rfc4646Languages  Pointers to a Null-terminated RFC 4646 language codes string containing\r
-                               one or more RFC 4646 language codes.\r
-  \r
-  @retval NULL                 Invalid or unsupported RFC 4646 language code found.\r
-  @retval NULL                 Out of memory.\r
-  @retval !NULL                Pointer to the allocate buffer containing the Null-terminated converted language codes string.\r
-                               This string is composed of one or more ISO 639-2 language codes.\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-ConvertLanguagesRfc4646ToIso639 (\r
-  IN CONST CHAR8  *Rfc4646Languages\r
-  )\r
-{\r
-  UINTN  NumLanguages;\r
-  UINTN  Iso639Index;\r
-  UINTN  Rfc4646Index;\r
-  CHAR8  *Iso639Languages;\r
-\r
-  ASSERT (Rfc4646Languages != NULL);\r
-\r
-  //\r
-  // Determine the number of languages in the RFC 4646 language codes string\r
-  //\r
-  for (Rfc4646Index = 0, NumLanguages = 1; Rfc4646Languages[Rfc4646Index] != '\0'; Rfc4646Index++) {\r
-    if (Rfc4646Languages[Rfc4646Index] == ';') {\r
-      NumLanguages++;\r
-    }\r
-  }\r
-  \r
-  //\r
-  // Allocate buffer for ISO 639-2 language codes string\r
-  //\r
-  Iso639Languages = AllocateZeroPool (NumLanguages * 3 + 1);\r
-  if (Iso639Languages == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Do the conversion for each RFC 4646 language code\r
-  //\r
-  for (Rfc4646Index = 0, Iso639Index = 0; Rfc4646Languages[Rfc4646Index] != '\0';) {\r
-    if (ConvertRfc4646ToIso639 (&Iso639Languages[Iso639Index], &Rfc4646Languages[Rfc4646Index])) {\r
-      Iso639Index += 3;\r
-    } else {\r
-      FreePool (Iso639Languages);\r
-      return NULL;\r
-    }\r
-    //\r
-    // Locate next language code\r
-    //\r
-    while (Rfc4646Languages[Rfc4646Index] != ';' && Rfc4646Languages[Rfc4646Index] != '\0') {\r
-      Rfc4646Index++;\r
-    }\r
-    if (Rfc4646Languages[Rfc4646Index] == ';') {\r
-      Rfc4646Index++;\r
-    }\r
-  }\r
-  Iso639Languages[Iso639Index] = '\0';\r
-  return Iso639Languages;\r
-}\r
diff --git a/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf b/EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf
deleted file mode 100644 (file)
index 8b29599..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#/** @file\r
-# Instance of Language Library.\r
-#\r
-# The Language Library implementation that provides functions for language conversion\r
-#  between ISO 639-2 and RFC 4646 language codes.\r
-#\r
-# Copyright (c) 2009, Intel Corporation\r
-#\r
-#  All rights reserved. This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = LanguageLib\r
-  FILE_GUID                      = 283cad13-a151-4d55-be2d-96ea57392a82 \r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = LanguageLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  LanguageLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  EdkCompatibilityPkg/EdkCompatibilityPkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  DebugLib\r
-  MemoryAllocationLib\r
diff --git a/EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.c b/EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.c
new file mode 100644 (file)
index 0000000..0595db7
--- /dev/null
@@ -0,0 +1,501 @@
+/** @file\r
+  Language Library implementation that provides functions for language conversion\r
+  between ISO 639-2 and RFC 4646 language codes.\r
+\r
+  Copyright (c) 2009, Intel Corporation<BR>\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Library/LanguageLib.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+//\r
+// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes\r
+// Each entry is 5 CHAR8 values long.  The first 3 CHAR8 values are the ISO 639-2 code.\r
+// The last 2 CHAR8 values are the ISO 639-1 code.\r
+//\r
+// ISO 639-2 B codes and deprecated ISO 639-1 codes are not supported.\r
+//\r
+// Commonly used language codes such as English and French are put in the front of the table for quick match.\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mIso639ToRfc4646ConversionTable[] =\r
+"\\r
+engen\\r
+frafr\\r
+aaraa\\r
+abkab\\r
+aveae\\r
+afraf\\r
+akaak\\r
+amham\\r
+argan\\r
+araar\\r
+asmas\\r
+avaav\\r
+aymay\\r
+azeaz\\r
+bakba\\r
+belbe\\r
+bulbg\\r
+bihbh\\r
+bisbi\\r
+bambm\\r
+benbn\\r
+bodbo\\r
+brebr\\r
+bosbs\\r
+catca\\r
+chece\\r
+chach\\r
+cosco\\r
+crecr\\r
+cescs\\r
+chucu\\r
+chvcv\\r
+cymcy\\r
+danda\\r
+deude\\r
+divdv\\r
+dzodz\\r
+eweee\\r
+ellel\\r
+epoeo\\r
+spaes\\r
+estet\\r
+euseu\\r
+fasfa\\r
+fulff\\r
+finfi\\r
+fijfj\\r
+faofo\\r
+fryfy\\r
+glega\\r
+glagd\\r
+glggl\\r
+grngn\\r
+gujgu\\r
+glvgv\\r
+hauha\\r
+hebhe\\r
+hinhi\\r
+hmoho\\r
+hrvhr\\r
+hatht\\r
+hunhu\\r
+hyehy\\r
+herhz\\r
+inaia\\r
+indid\\r
+ileie\\r
+iboig\\r
+iiiii\\r
+ipkik\\r
+idoio\\r
+islis\\r
+itait\\r
+ikuiu\\r
+jpnja\\r
+javjv\\r
+katka\\r
+konkg\\r
+kikki\\r
+kuakj\\r
+kazkk\\r
+kalkl\\r
+khmkm\\r
+kankn\\r
+korko\\r
+kaukr\\r
+kasks\\r
+kurku\\r
+komkv\\r
+corkw\\r
+kirky\\r
+latla\\r
+ltzlb\\r
+luglg\\r
+limli\\r
+linln\\r
+laolo\\r
+litlt\\r
+lublu\\r
+lavlv\\r
+mlgmg\\r
+mahmh\\r
+mrimi\\r
+mkdmk\\r
+malml\\r
+monmn\\r
+marmr\\r
+msams\\r
+mltmt\\r
+myamy\\r
+nauna\\r
+nobnb\\r
+ndend\\r
+nepne\\r
+ndong\\r
+nldnl\\r
+nnonn\\r
+norno\\r
+nblnr\\r
+navnv\\r
+nyany\\r
+ocioc\\r
+ojioj\\r
+ormom\\r
+orior\\r
+ossos\\r
+panpa\\r
+plipi\\r
+polpl\\r
+pusps\\r
+porpt\\r
+quequ\\r
+rohrm\\r
+runrn\\r
+ronro\\r
+rusru\\r
+kinrw\\r
+sansa\\r
+srdsc\\r
+sndsd\\r
+smese\\r
+sagsg\\r
+sinsi\\r
+slksk\\r
+slvsl\\r
+smosm\\r
+snasn\\r
+somso\\r
+sqisq\\r
+srpsr\\r
+sswss\\r
+sotst\\r
+sunsu\\r
+swesv\\r
+swasw\\r
+tamta\\r
+telte\\r
+tgktg\\r
+thath\\r
+tirti\\r
+tuktk\\r
+tgltl\\r
+tsntn\\r
+tonto\\r
+turtr\\r
+tsots\\r
+tattt\\r
+twitw\\r
+tahty\\r
+uigug\\r
+ukruk\\r
+urdur\\r
+uzbuz\\r
+venve\\r
+vievi\\r
+volvo\\r
+wlnwa\\r
+wolwo\\r
+xhoxh\\r
+yidyi\\r
+yoryo\\r
+zhaza\\r
+zhozh\\r
+zulzu\\r
+";\r
+\r
+/**\r
+  Converts upper case ASCII characters in an ASCII string to lower case ASCII \r
+  characters in an ASCII string.\r
+\r
+  If a an ASCII character in Source is in the range 'A'..'Z', then it is converted \r
+  to an ASCII character in the range 'a'..'z' in Destination.  Otherwise, no \r
+  conversion is performed.  Length ASCII characters from Source are convertered and\r
+  stored in Destination.\r
+\r
+  @param  Destination  An ASCII string to store the results of the conversion.\r
+  @param  Source       The source ASCII string of the conversion.\r
+  @param  Length       The number of ASCII characters to convert.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalLanguageLibToLower (\r
+  OUT CHAR8        *Destination,\r
+  IN  CONST CHAR8  *Source,\r
+  IN  UINTN        Length\r
+  )\r
+{\r
+  for (; Length > 0; Length--, Destination++, Source++) {\r
+    *Destination = (CHAR8)((*Source >= 'A' && *Source <= 'Z') ? *Source + ('a' - 'A') : *Source);\r
+  }\r
+}\r
+\r
+/**\r
+  Convert an ISO 639-2 language code to a RFC 4646 language code.\r
+  If the ISO 639-2 language code has a corresponding ISO 639-1 code, then the ISO 639-1\r
+  code is returned. Else the original ISO 639-2 code is returned. The returned RFC 4646\r
+  language code is composed of only a primary language subtag.\r
+\r
+  If Iso639Language is NULL, then ASSERT.\r
+  If Rfc4646Language is NULL, then ASSERT.\r
+\r
+  @param[out] Rfc4646Language  Pointers to a buffer large enough for an ASCII string\r
+                               which reprsents a RFC 4646 language code containging only\r
+                               either a ISO 639-1 or ISO 639-2 primary language subtag.\r
+                               This string is Null-terminated.\r
+  @param[in]  Iso639Language   Pointer to a 3-letter ASCII string which represents\r
+                               an ISO 639-2 language code. This string is not required\r
+                               to be Null-terminated.\r
+\r
+  @retval TRUE                 The ISO 639-2 language code was converted to a ISO 639-1 code.\r
+  @retval FALSE                The language code does not have corresponding ISO 639-1 code.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ConvertIso639ToRfc4646 (\r
+  OUT CHAR8        *Rfc4646Language,\r
+  IN  CONST CHAR8  *Iso639Language\r
+  )\r
+{\r
+  CONST CHAR8  *Match;\r
+  \r
+  ASSERT (Iso639Language != NULL);\r
+  ASSERT (Rfc4646Language != NULL);\r
+\r
+  //\r
+  // Convert first 3 characters of Iso639Language to lower case ASCII characters in Rfc4646Language\r
+  //\r
+  InternalLanguageLibToLower (Rfc4646Language, Iso639Language, 3);\r
+  Rfc4646Language[3] = '\0';\r
+\r
+  Match = mIso639ToRfc4646ConversionTable;\r
+  do {\r
+    Match = AsciiStrStr (Match, Rfc4646Language);\r
+    if (Match == NULL) {\r
+      return FALSE;\r
+    }\r
+    if (((Match - mIso639ToRfc4646ConversionTable) % 5) == 0) {\r
+      break;\r
+    }\r
+    ++Match;\r
+  } while (TRUE);\r
+  Rfc4646Language[0] = Match[3];\r
+  Rfc4646Language[1] = Match[4];\r
+  Rfc4646Language[2] = '\0';\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Convert a RFC 4646 language code to an ISO 639-2 language code. The primary language\r
+  subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code. If the primary\r
+  language subtag is an ISO 639-1 code, then it is converted to its corresponding ISO 639-2\r
+  code (T code if applies). Else the ISO 639-2 code is returned.\r
+\r
+  If Rfc4646Language is NULL, then ASSERT.\r
+  If Iso639Language is NULL, then ASSERT.\r
+\r
+  @param[out] Iso639Language   Pointers to a buffer large enough for a 3-letter ASCII string\r
+                               which reprsents an ISO 639-2 language code. The string is Null-terminated.\r
+  @param[in]  Rfc4646Language  Pointer to a RFC 4646 language code string. This string is terminated\r
+                               by a NULL or a ';' character.\r
+\r
+  @retval TRUE                 Language code converted successfully.\r
+  @retval FALSE                The RFC 4646 language code is invalid or unsupported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ConvertRfc4646ToIso639 (\r
+  OUT CHAR8        *Iso639Language,\r
+  IN  CONST CHAR8  *Rfc4646Language\r
+  )\r
+{\r
+  CONST CHAR8 *Match;\r
+  \r
+  ASSERT (Rfc4646Language != NULL);\r
+  ASSERT (Iso639Language != NULL);\r
+\r
+  //\r
+  // RFC 4646 language code check before determining \r
+  // if the primary language subtag is ISO 639-1 or 639-2 code\r
+  //\r
+  if (Rfc4646Language[0] == '\0' || Rfc4646Language[1] == '\0') {\r
+    return FALSE;\r
+  }\r
+  \r
+  //\r
+  // Check if the primary language subtag is ISO 639-1 code\r
+  //\r
+  if (Rfc4646Language[2] == ';' || Rfc4646Language[2] == '-' || Rfc4646Language[2] == '\0') {\r
+    //\r
+    // Convert first 2 characters of Rfc4646Language to lower case ASCII characters in Iso639Language\r
+    //\r
+    InternalLanguageLibToLower (Iso639Language, Rfc4646Language, 2);\r
+    //\r
+    // Convert ISO 639-1 code to ISO 639-2 code\r
+    //\r
+    Iso639Language[2] = '\0';\r
+    Match = mIso639ToRfc4646ConversionTable;\r
+    do {\r
+      Match = AsciiStrStr (Match, Iso639Language);\r
+      if (Match == NULL) {\r
+        return FALSE;\r
+      }\r
+      if (((Match - mIso639ToRfc4646ConversionTable) % 5) == 3) {\r
+        break;\r
+      }\r
+      ++Match;\r
+    } while (TRUE);\r
+    Rfc4646Language = Match - 3;\r
+  } else if (!(Rfc4646Language[3] == ';' || Rfc4646Language[3] == '-' || Rfc4646Language[3] == '\0')) {\r
+    return FALSE;\r
+  }\r
+  Iso639Language[0] = Rfc4646Language[0];\r
+  Iso639Language[1] = Rfc4646Language[1];\r
+  Iso639Language[2] = Rfc4646Language[2];\r
+  Iso639Language[3] = '\0';\r
+  return TRUE;  \r
+}\r
+\r
+/**\r
+  Convert ISO 639-2 language codes to RFC 4646 codes and return the converted codes.\r
+  Caller is responsible for freeing the allocated buffer.\r
+\r
+  If Iso639Languages is NULL, then ASSERT.\r
+\r
+  @param[in] Iso639Languages  Pointers to a Null-terminated ISO 639-2 language codes string containing\r
+                              one or more ISO 639-2 3-letter language codes.\r
+  \r
+  @retval NULL                Invalid ISO 639-2 language code found.\r
+  @retval NULL                Out of memory.\r
+  @retval !NULL               Pointer to the allocate buffer containing the Null-terminated converted language codes string.\r
+                              This string is composed of one or more RFC4646 language codes each of which has only\r
+                              ISO 639-1 2-letter primary language subtag.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+ConvertLanguagesIso639ToRfc4646 (\r
+  IN CONST CHAR8  *Iso639Languages\r
+  )\r
+{\r
+  UINTN  Length;\r
+  UINTN  Iso639Index;\r
+  UINTN  Rfc4646Index;\r
+  CHAR8  *Rfc4646Languages;\r
+  \r
+  ASSERT (Iso639Languages != NULL);\r
+  \r
+  //\r
+  // The length of ISO 639-2 lanugage codes string must be multiple of 3\r
+  //\r
+  Length = AsciiStrLen (Iso639Languages);\r
+  if (Length % 3) {\r
+    return NULL;\r
+  }\r
+  \r
+  //\r
+  // Allocate buffer for RFC 4646 language codes string\r
+  //\r
+  Rfc4646Languages = AllocatePool (Length + (Length / 3));\r
+  if (Rfc4646Languages == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  for (Iso639Index = 0, Rfc4646Index = 0; Iso639Languages[Iso639Index] != '\0'; Iso639Index += 3) {\r
+    if (ConvertIso639ToRfc4646 (&Rfc4646Languages[Rfc4646Index], &Iso639Languages[Iso639Index])) {\r
+      Rfc4646Index += 2;\r
+    } else {\r
+      Rfc4646Index += 3;\r
+    }\r
+    Rfc4646Languages[Rfc4646Index++] = ';';\r
+  }\r
+  Rfc4646Languages[Rfc4646Index - 1] = '\0';\r
+  return Rfc4646Languages;\r
+}\r
+\r
+/**\r
+  Convert RFC 4646 language codes to ISO 639-2 codes and return the converted codes.\r
+  The primary language subtag of the RFC 4646 code must be either an ISO 639-1 or 639-2 code.\r
+  Caller is responsible for freeing the allocated buffer.\r
+\r
+  If Rfc4646Languages is NULL, then ASSERT.\r
+\r
+  @param[in] Rfc4646Languages  Pointers to a Null-terminated RFC 4646 language codes string containing\r
+                               one or more RFC 4646 language codes.\r
+  \r
+  @retval NULL                 Invalid or unsupported RFC 4646 language code found.\r
+  @retval NULL                 Out of memory.\r
+  @retval !NULL                Pointer to the allocate buffer containing the Null-terminated converted language codes string.\r
+                               This string is composed of one or more ISO 639-2 language codes.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+ConvertLanguagesRfc4646ToIso639 (\r
+  IN CONST CHAR8  *Rfc4646Languages\r
+  )\r
+{\r
+  UINTN  NumLanguages;\r
+  UINTN  Iso639Index;\r
+  UINTN  Rfc4646Index;\r
+  CHAR8  *Iso639Languages;\r
+\r
+  ASSERT (Rfc4646Languages != NULL);\r
+\r
+  //\r
+  // Determine the number of languages in the RFC 4646 language codes string\r
+  //\r
+  for (Rfc4646Index = 0, NumLanguages = 1; Rfc4646Languages[Rfc4646Index] != '\0'; Rfc4646Index++) {\r
+    if (Rfc4646Languages[Rfc4646Index] == ';') {\r
+      NumLanguages++;\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Allocate buffer for ISO 639-2 language codes string\r
+  //\r
+  Iso639Languages = AllocateZeroPool (NumLanguages * 3 + 1);\r
+  if (Iso639Languages == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Do the conversion for each RFC 4646 language code\r
+  //\r
+  for (Rfc4646Index = 0, Iso639Index = 0; Rfc4646Languages[Rfc4646Index] != '\0';) {\r
+    if (ConvertRfc4646ToIso639 (&Iso639Languages[Iso639Index], &Rfc4646Languages[Rfc4646Index])) {\r
+      Iso639Index += 3;\r
+    } else {\r
+      FreePool (Iso639Languages);\r
+      return NULL;\r
+    }\r
+    //\r
+    // Locate next language code\r
+    //\r
+    while (Rfc4646Languages[Rfc4646Index] != ';' && Rfc4646Languages[Rfc4646Index] != '\0') {\r
+      Rfc4646Index++;\r
+    }\r
+    if (Rfc4646Languages[Rfc4646Index] == ';') {\r
+      Rfc4646Index++;\r
+    }\r
+  }\r
+  Iso639Languages[Iso639Index] = '\0';\r
+  return Iso639Languages;\r
+}\r
diff --git a/EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf b/EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
new file mode 100644 (file)
index 0000000..715658c
--- /dev/null
@@ -0,0 +1,41 @@
+#/** @file\r
+# Instance of Language Library.\r
+#\r
+# The Language Library implementation that provides functions for language conversion\r
+#  between ISO 639-2 and RFC 4646 language codes.\r
+#\r
+# Copyright (c) 2009, Intel Corporation\r
+#\r
+#  All rights reserved. This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = UefiLanguageLib\r
+  FILE_GUID                      = 283cad13-a151-4d55-be2d-96ea57392a82 \r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = LanguageLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  UefiLanguageLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EdkCompatibilityPkg/EdkCompatibilityPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  MemoryAllocationLib\r
index 9830f4f0dc6acc42f82a8f4dca33be1dd6fbe67e..51130e5c1df6dff70a16f65df983530fedde688c 100644 (file)
@@ -61,8 +61,8 @@ define GCC_MACRO                 = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
   PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
   PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf\r
-  LanguageLib|EdkCompatibilityPkg/Compatibility/Library/LanguageLib.inf\r
-  \r
+  LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf\r
+    \r
 [LibraryClasses.common.PEIM]\r
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
   MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r