title: How to deal with the iOS detect the NSString language, English can not be detected accurately?
body: <p><strong>Method：</strong></p>
  
  <pre><code>- (NSString *)languageForString:(NSString *) text{
      return (__bridge NSString *)CFStringTokenizerCopyBestStringLanguage((CFStringRef)[text cStringUsingEncoding:NSUnicodeStringEncoding], CFRangeMake(0, MIN(text.length,100)));
  }
  </code></pre>
  
  <p><strong>Use：</strong></p>
  
  <pre><code>NSLog(@"\"%@\" language is %@",@"Tokenizer",[self languageForString:@"tokenizer"]);
  NSLog(@"\"%@\" language is %@",@"Tokenizer detect",[self languageForString:@"Tokenizer detect"]);
  NSLog(@"\"%@\" language is %@",@"detect",[self languageForString:@"detect"]);
  NSLog(@"\"%@\" language is %@",@"我们",[self languageForString:@"我们"]);
  NSLog(@"\"%@\" language is %@",@"집안일",[self languageForString:@"집안일"]);
  NSLog(@"\"%@\" language is %@",@"Démocratie",[self languageForString:@"Démocratie"]);
  NSLog(@"\"%@\" language is %@",@"Tokenizer English",[self languageForString:@"Tokenizer English"]);
  NSLog(@"\"%@\" language is %@",@"ここはデパートです",[self languageForString:@"ここはデパートです"]);
  </code></pre>
  
  <p><strong>Output：</strong><br/></p>
  
  <pre><code>2013-01-09 16:12:28.582 TestCommandLine[6478:c07] "Tokenizer" language is tr&lt;br/&gt;
  2013-01-09 16:12:28.586 TestCommandLine[6478:c07] "Tokenizer detect" language is tr&lt;br/&gt;
  2013-01-09 16:12:28.586 TestCommandLine[6478:c07] "detect" language is cs&lt;br/&gt;
  2013-01-09 16:12:28.587 TestCommandLine[6478:c07] "我们" language is zh-Hans&lt;br/&gt;
  2013-01-09 16:12:28.560 TestCommandLine[6478:c07] "집안일" language is ko&lt;br/&gt;
  2013-01-09 16:12:28.577 TestCommandLine[6478:c07] "Démocratie" language is fr&lt;br/&gt;
  2013-01-09 16:12:28.590 TestCommandLine[6478:c07] "Tokenizer English" language is en&lt;br/&gt;
  2013-01-09 16:12:28.591 TestCommandLine[6478:c07] "ここはデパートです" language is ja&lt;br/&gt;
  </code></pre>
  
  <p><strong>How to become like：</strong><br/></p>
  
  <pre><code>2013-01-09 16:12:28.582 TestCommandLine[6478:c07] "Tokenizer" language is en&lt;br/&gt;
  2013-01-09 16:12:28.586 TestCommandLine[6478:c07] "Tokenizer detect" language is en&lt;br/&gt;
  2013-01-09 16:12:28.586 TestCommandLine[6478:c07] "detect" language is en&lt;br/&gt;
  2013-01-09 16:12:28.587 TestCommandLine[6478:c07] "我们" language is zh-Hans&lt;br/&gt;
  2013-01-09 16:12:28.560 TestCommandLine[6478:c07] "집안일" language is ko&lt;br/&gt;
  2013-01-09 16:12:28.577 TestCommandLine[6478:c07] "Démocratie" language is fr&lt;br/&gt;
  2013-01-09 16:12:28.590 TestCommandLine[6478:c07] "Tokenizer English" language is en&lt;br/&gt;
  2013-01-09 16:12:28.591 TestCommandLine[6478:c07] "ここはデパートです" language is ja&lt;br/&gt;
  </code></pre>