twitter-text icon indicating copy to clipboard operation
twitter-text copied to clipboard

Wrong character count

Open freeman2kbr opened this issue 5 years ago • 6 comments

When using the JS version and passing the following message through getTweetLength, it returns exactly 280 characters but Twitter considers it having 282.

"Para obter o bilhete único comum você faz a solicitação pelo site da SPTrans e retira no posto que escolher, personalizando com sua foto e nome (inclusive com o nome social 😉). Não esqueça de comprar créditos pelo aplicativo da RPC. 😍 #RPCInforma #BilheteUnico #SãoPaulo #SPTran"

Edit: Version 2.0.5 - https://github.com/twitter/twitter-text/blob/master/js/pkg/twitter-text-2.0.5.js

freeman2kbr avatar Sep 25 '18 20:09 freeman2kbr

Hi @freeman2kbr! Can you explain what you mean by this?

it returns exactly 280 characters but Twitter considers it having 282.

Twitter uses whatever is returned by twitter-text as the source of truth. And I am able to create a tweet with the text you quoted.

kaushlakers avatar Sep 26 '18 06:09 kaushlakers

Strange... I attached a image from twitter using this same text and it says -2 characters remaining. tweet

freeman2kbr avatar Sep 27 '18 12:09 freeman2kbr

I am seeing this same behavior on different text using library [email protected].

spmeltwater avatar Oct 01 '18 14:10 spmeltwater

I'm having the same issue with a different text using [email protected] in ruby. The library tells me 258 chars, and twitter says I have 289 chars. I thought the issue was some links which did not have http:// before, but adding it just bumps the count to 277, still different from twitter interface.

This is an equivalent text:

Le mardi 21/12, 🐘[email protected] sera à #riodejan en #cancan (au côté de nos ami⋅e⋅s de utopie.ch de chisslinux.org et de la uth.ch ) pour une conférence « Ruelles alternatives aux multinationales du atlanique ? »

http://www.some-url.com/

image

> Twitter::TwitterText::Validation.parse_tweet(text)
=> {:weighted_length=>258, :valid=>true, :permillage=>921, :valid_range_start=>0, :valid_range_end=>246, :display_range_start=>0, :display_range_end=>246}

renatolond avatar Oct 01 '18 18:10 renatolond

Hi guys, is this problem solved in any version? I have the same issue with version 3.0.1 on 2020 Jan

d-nguyen-tmh avatar Feb 07 '20 01:02 d-nguyen-tmh

1️⃣ character is counted as 1 character with twitter-text but counted as 2 characters on Twitter UI Tested on twitter-text 3.0.1

ducnv55 avatar Feb 10 '20 01:02 ducnv55