nst / STTwitter

A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1
BSD 3-Clause "New" or "Revised" License
999 stars 161 forks source link

st_numberOfCharactersInATweet counting Emoji's as 2 characters while Twitter accepts as 1 #210

Closed goodmorningbob closed 9 years ago

goodmorningbob commented 9 years ago

Hi,

When including Emoji's in the tweet text the st_numberOfCharactersInATweet method is counting these as 2 characters while Twitter accepts them as 1 character.

As a temporary fix i have modified -

as follows -

// NSInteger count = [s length]; __block NSInteger count = 0; [s enumerateSubstringsInRange:NSMakeRange(0, s.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString subString, NSRange subStringRange, NSRange enclosingRange, BOOL stop) { count++; }];

This seems to give a correct count for Twitter but would be interested to get your take on this as I am not overly familiar with the Twitter API.

Thanks.

/jh

nst commented 9 years ago

You are perfectly right, thank you for spotting this error.