Handle the case where the country code is empty.
@@ -41,7 +41,13 @@ LOGMANAGER_INSTANCE
// Obtain semantics values
NSBundle* bundle = [NSBundle mainBundle];
- std::string strUserLocale = std::string([[NSString stringWithFormat:@"%@-%@", [[NSLocale currentLocale] languageCode], [[NSLocale currentLocale] countryCode]] UTF8String]);
+ NSLocale* locale = [NSLocale currentLocale];
+ std::string strUserLocale = std::string([[locale languageCode] UTF8String]);
+ NSString* countryCode = [locale countryCode];
+ if ([countryCode length] != 0)
+ {
+ strUserLocale += [[NSString stringWithFormat:@"-%@", countryCode] UTF8String];
+ }
NSString* bundleVersion = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
std::string strBundleVersion = bundleVersion == nil ? std::string {} : std::string([bundleVersion UTF8String]);
