Ios 给定区域设置的单词分隔符

Ios 给定区域设置的单词分隔符,ios,objective-c,localization,nslocale,Ios,Objective C,Localization,Nslocale,我如何知道语言NSLocale是否使用空格来界定句子中的单词(如英语或其他罗马语言)或不使用(如日语) 我想在…下找到这些信息不知道吗?我真的需要为此设置自己的词典吗。如果您能提供任何建议或相关资源,我将不胜感激。您可以使用NSLocal Components Key'NSLocaleExemplarCharterSet获取该语言中的字符集,然后查看空格是否是该语言字符集的一部分 NSLocale *jpLocale = [[NSLocal alloc] initWithLocalDentifi

我如何知道语言
NSLocale
是否使用空格来界定句子中的单词(如英语或其他罗马语言)或不使用(如日语)


我想在…下找到这些信息不知道吗?我真的需要为此设置自己的词典吗。如果您能提供任何建议或相关资源,我将不胜感激。

您可以使用NSLocal Components Key'
NSLocaleExemplarCharterSet
获取该语言中的字符集,然后查看空格是否是该语言字符集的一部分

NSLocale *jpLocale = [[NSLocal alloc] initWithLocalDentifier: @"ja_JP"];

NSCharacterSet *jpCharSet = (NSCharacterSet *)[jpLocale objectForKey: NSLocaleExemplarCharacterSet]; 

[jpCharSet characterIsMember: ' '] ? NSLog("Yeah it uses space"); : NSLog("Nope"); 

我还没有找到一个很好的解决办法。作为一种解决方法,我使用
NSDateFormatter

NSDate* exampleDate = [NSDate dateWithTimeIntervalSince1970:0];
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.locale = [NSLocale currentLocale];
dateFormatter.dateStyle = NSDateFormatterFullStyle;
NSString *testString = [dateFormatter stringFromDate:exampleDate];

BOOL localeLikelyUsesSpaceAsDelimitters = [testString rangeOfString:@" "].location == NSNotFound;

更好的主意?

没错。欢迎来到日本。:)