Skip to content

Commit

Permalink
Merge pull request #409 from bettar/dateFormat
Browse files Browse the repository at this point in the history
Prevent throwing exception when encountering country code 10485
  • Loading branch information
tfussell authored Sep 8, 2019
2 parents 8f39375 + 2b221fe commit f302601
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/detail/number_format/number_formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const std::unordered_map<int, std::string> known_locales()
{0x457, "Konkani"}, {0x458, "Manipuri"}, {0x459, "Sindhi"}, {0x460, "Kashmiri"}, {0x461, "Nepali"},
{0x462, "Frisian - Netherlands"}, {0x464, "Filipino"}, {0x465, "Divehi; Dhivehi; Maldivian"},
{0x466, "Edo"}, {0x470, "Igbo - Nigeria"}, {0x474, "Guarani - Paraguay"}, {0x476, "Latin"},
{0x477, "Somali"}, {0x481, "Maori"}, {0x801, "Arabic - Iraq"}, {0x804, "Chinese - China"},
{0x477, "Somali"}, {0x481, "Maori"}, {0x485, "sah-RU"}, {0x801, "Arabic - Iraq"}, {0x804, "Chinese - China"},
{0x807, "German - Switzerland"}, {0x809, "English - Great Britain"}, {0x810, "Italian - Switzerland"},
{0x813, "Dutch - Belgium"}, {0x814, "Norwegian - Nynorsk"}, {0x816, "Portuguese - Portugal"},
{0x818, "Romanian - Moldova"}, {0x819, "Russian - Moldova"}, {0x843, "Uzbek - Cyrillic"},
Expand Down Expand Up @@ -1066,6 +1066,7 @@ std::pair<format_locale, std::string> number_format_parser::locale_from_string(c
}

auto country_code = std::stoi(country_code_string, nullptr, 16);
country_code &= 0xFFFF;

for (const auto &known_locale : known_locales())
{
Expand Down
1 change: 1 addition & 0 deletions source/detail/number_format/number_formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ enum class format_locale
latin = 0x476,
somali = 0x477,
maori = 0x481,
yakut = 0x485,
arabic_iraq = 0x801,
chinese_china = 0x804,
german_switzerland = 0x807,
Expand Down

0 comments on commit f302601

Please sign in to comment.