mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
fix for #368
This commit is contained in:
parent
d6bb6deff6
commit
79a1a6b944
2 changed files with 33 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
2024-02-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSLocale.m: (+canonicalLocaleIdentifierFromString:)
|
||||
Fix for #368 ... standardise hyphen to underscore then check for
|
||||
presence of two underscores and delete the script identifier between
|
||||
them, as suggested by the existing comments. Avoids the exception.
|
||||
|
||||
2024-02-02 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
Source/NSString.m: Return empty string of correct class when loading
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#import "Foundation/NSNumberFormatter.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
|
||||
#if defined(HAVE_UNICODE_ULOC_H)
|
||||
|
@ -272,18 +273,36 @@ static NSRecursiveLock *classLock = nil;
|
|||
if (result == nil)
|
||||
result = string;
|
||||
|
||||
// Strip script info from locale
|
||||
/* Strip script info (if present) from locale.
|
||||
* We try to cope with zh-Hant_TW or zh_Hant-TW
|
||||
*/
|
||||
mStr = nil;
|
||||
range = [result rangeOfString: @"-"];
|
||||
if (range.length > 0)
|
||||
{
|
||||
mStr = [NSMutableString stringWithString: result];
|
||||
[mStr replaceString: @"-" withString: @"_"];
|
||||
result = mStr;
|
||||
}
|
||||
range = [result rangeOfString: @"_"];
|
||||
if (range.location != NSNotFound)
|
||||
{
|
||||
NSUInteger start = range.location;
|
||||
NSUInteger length;
|
||||
range = [result rangeOfString: @"_"];
|
||||
length = range.location - start;
|
||||
|
||||
mStr = [NSMutableString stringWithString: result];
|
||||
[mStr deleteCharactersInRange: NSMakeRange (start, length)];
|
||||
|
||||
range = [result rangeOfString: @"_" options: NSBackwardsSearch];
|
||||
if (range.location != start)
|
||||
{
|
||||
NSUInteger length = range.location - start;
|
||||
|
||||
if (nil == mStr)
|
||||
{
|
||||
mStr = [NSMutableString stringWithString: result];
|
||||
}
|
||||
[mStr deleteCharactersInRange: NSMakeRange(start, length)];
|
||||
}
|
||||
}
|
||||
if (mStr)
|
||||
{
|
||||
result = [NSString stringWithString: mStr];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue