/* For example: SupportedLang = "engfraengfra" Index = "1" Iso639Language = TRUE The return value is "fra". Another example: SupportedLang = "en;fr;en-US;fr-FR" Index = "1" Iso639Language = FALSE The return value is "fr". */
CHAR8* GetLangFromSupportedLangCodes(IN CHAR8 *SupportedLang, IN UINTN Index, IN BOOLEAN Iso639Language)
/* For example: SupportedLang = "engfraengfra" Index = "1" Iso639Language = TRUE The return value is "fra". Another example: SupportedLang = "en;fr;en-US;fr-FR" Index = "1" Iso639Language = FALSE The return value is "fr". */
CHAR8* GetLangFromSupportedLangCodes(IN CHAR8 *SupportedLang, IN UINTN Index, IN BOOLEAN Iso639Language)
{
  UINTN  SubIndex;
  UINTN  CompareLength;
  CHAR8  *Supported;
  SubIndex  = 0;
  Supported = SupportedLang;
  if (Iso639Language) {
    CompareLength                              = ISO_639_2_ENTRY_SIZE;
    mVariableModuleGlobal->Lang[CompareLength] = '\0';
    return CopyMem (mVariableModuleGlobal->Lang, SupportedLang + Index * CompareLength, CompareLength);
  } else {
    while (TRUE) {
      for (CompareLength = 0; *Supported != ';' && *Supported != '\0'; CompareLength++) {
        Supported++;
      }
      if ((*Supported == '\0') && (SubIndex != Index)) {
        ASSERT (FALSE);
        return NULL;
      }
      if (SubIndex == Index) {
        mVariableModuleGlobal->PlatformLang[CompareLength] = '\0';
        return CopyMem (mVariableModuleGlobal->PlatformLang, Supported - CompareLength, CompareLength);
      }
      SubIndex++;
      for ( ; *Supported != '\0' && *Supported == ';'; Supported++) {
      }
    }
  }
}