i have counted (all character, spaces included) to be 244 but calc_expected_status_length() shows it be 283 for some reason?
i have taken all the emoji out of the string and counted them alone and calc_expected_status_length() return a length of 60 and i only see 28 individual emoji?
for now i have resorted to using a modified version of the solution mentioned here, I removed the check for \n since it seems twitter actually counts those towards the total character count.
num_emoji = sum(tweets.count(emoji) for emoji in UNICODE_EMOJI) # accurately count and track emoji
ignored_chars = UNICODE_EMOJI.copy() # thanks to https://stackoverflow.com/q/56214183/11456464
num_other = sum(0 if char in ignored_chars else 1 for char in tweet)
print(num_emoji, num_other, str((num_emoji * 2) + num_other))
not sure if this is the proper way to go about it or not but it seems to work fairly well for me as of right now.
i have a string that i put together like so
a generated output can be seen here
i have counted (all character, spaces included) to be 244 but
calc_expected_status_length()
shows it be 283 for some reason?i have taken all the emoji out of the string and counted them alone and
calc_expected_status_length()
return a length of 60 and i only see 28 individual emoji?there are 216 other characters (not counting emoji)
working code cane be seen here.
thank you in advance as this is the only way i've found to count characters even this accurately for verifying a tweets length.
please let me know if i can provide anymore info on this issue
edit:
also worth noting is twitter shows this exact tweet having 4 character (i just copy and pasted it from here to Twitter)
Edit 2
Seem Twitter started counting emoji as 2 characters each no matter which one it is
https://twittercommunity.com/t/new-update-to-the-twitter-text-library-emoji-character-count/114607
Edit 3
for now i have resorted to using a modified version of the solution mentioned here, I removed the check for
\n
since it seems twitter actually counts those towards the total character count.not sure if this is the proper way to go about it or not but it seems to work fairly well for me as of right now.