Str

class pyrogram.types.Str[source]

A message text or caption, indexed the way Telegram counts it.

Entity offsets and lengths are counted in UTF-16 units, so indexing and slicing count them too: text[entity.offset:entity.offset + entity.length] is that entity’s text. An emoji, and any other code point outside the Basic Multilingual Plane, takes two of those units, and a cut falling between them widens outward to the whole code point, so a slice can come back one code point longer at either end than it asked for. Half a code point is never returned.