diff --git a/x/posts/types/models.go b/x/posts/types/models.go index a05ec7eafa..05e1378315 100644 --- a/x/posts/types/models.go +++ b/x/posts/types/models.go @@ -158,6 +158,10 @@ func (p Post) GetMentionedUsers() []string { // GetTextLength returns the length of the post text func (p Post) GetTextLength() int { + // Counting graphemes instead of runes of bytes can provide a more accurate length of the text. + // This will also ensure that emojis are counted as a single character, which will grant a more consistent + // user experience with clients as well. + // Example: 🏳️‍🌈 (rainbow flag emoji) is 1 grapheme, 4 runes, and 14 bytes. return uniseg.GraphemeClusterCount(p.Text) } diff --git a/x/reactions/types/models.go b/x/reactions/types/models.go index caf68d091d..7ce5ea7353 100644 --- a/x/reactions/types/models.go +++ b/x/reactions/types/models.go @@ -125,6 +125,10 @@ func (v *FreeTextValue) isReactionValue() {} // GetLength returns the length of the reaction value func (v *FreeTextValue) GetLength() int { + // Counting graphemes instead of runes of bytes can provide a more accurate length of the text. + // This will also ensure that emojis are counted as a single character, which will grant a more consistent + // user experience with clients as well. + // Example: 🏳️‍🌈 (rainbow flag emoji) is 1 grapheme, 4 runes, and 14 bytes. return uniseg.GraphemeClusterCount(v.Text) }