Kankan

Guides

How X counts characters: emoji, links and the 280 limit

Updated · Lumen Lab

X counts a weighted length, not characters. In twitter-text, the open-source library X published for this, Latin letters and common punctuation count 1, most other characters count 2, every link counts 23, each emoji counts 2, and the total may not go over 280.

The weights

These values come from the version 3 configuration of twitter-text 3.1.0. We counted each example with our own implementation and with the library; they agree.

What you typeCounts as
a, é, Ж (Latin, accented Latin, Cyrillic)1 each
“ and the long dash1 each
… (the single ellipsis character), ™, €2 each
Korean, Chinese or Japanese characters2 each
😀2
👍🏽 or 👨‍👩‍👧 (one emoji built from several pieces)2
https://example.com23

The rule behind the table is a set of code point ranges. Characters up to U+10FF, which covers Latin, Greek, Cyrillic, Arabic, Hebrew and Thai among others, weigh 1, together with a few ranges of general punctuation. Everything else weighs 2.

Links are always 23

Every link counts as 23, whether it is 19 characters or 83. That includes a bare domain: example.com with no https:// in front still counts as 23, so “see example.com now” is 31, not 19.

Not everything with a dot is a link. The library only treats a word as one when it ends in a real domain ending, so file.txt counts as 8 ordinary characters.

Ad

Emoji are 2, with a catch

An emoji counts as 2 no matter how many code points it is made of. 👨‍👩‍👧 is five code points and still 2.

The catch is which emoji the library knows. Release 3.1.0 carries an older emoji list, and it counts sequences it does not recognise piece by piece. 🧑‍🚀 and ❤️‍🔥 each come out as 5 there. We ran all 3,773 emoji in Emoji 15.1 through both: 2,963 agree at 2, and 810 newer ones get a larger number from the library. Our counter gives every one of them 2, the same as the emoji the library does know. We could not test X's own composer, so if a brand-new emoji decides whether your post fits, check it there.

What 280 holds

  • 280 Latin letters.
  • 140 Korean, Chinese or Japanese characters.
  • 140 emoji.
  • A link plus 257 Latin characters, spaces included.

Text is normalised first, so an é typed as one character and an é typed as e plus a combining accent both count as 1.

How we checked

The regular expression our counter uses to find links is identical, character for character, to the one in twitter-text 3.1.0, and a test compares the two. On top of that, 1,655 sample texts mixing links, emoji and several scripts get the same weighted length and the same link positions from both.

See the weighted length of your own text as you type.

Open the character counter

Keep reading

Ad