From 2d67ddeeeac530092bd9c6b4524b1ef158b98008 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 20 Jan 2021 22:19:43 +0100 Subject: [PATCH] Don't map language code "und" The library uses empty strings if there's no value and the ISO language code mapping should not make and exception. --- localehelper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/localehelper.cpp b/localehelper.cpp index e963dbc..98b5bed 100644 --- a/localehelper.cpp +++ b/localehelper.cpp @@ -30,10 +30,13 @@ inline static bool isLanguageDefined_ISO_639_2(const std::string &languageSpecif */ static const std::string &languageName_ISO_639_2(const std::string &isoCode) { + static const std::string empty; + if (!isLanguageDefined_ISO_639_2(isoCode)) { + return empty; + } const auto &mapping = languageNames_ISO_639_2_b(); const auto i = mapping.find(isoCode); if (i == mapping.cend()) { - static const std::string empty; return empty; } return i->second;