# Why emoijs are not treated as one index

**URL:** https://discuss.prosemirror.net/t/why-emoijs-are-not-treated-as-one-index/6059
**Category:** Uncategorized
**Created:** [December 13, 2023, 6:25am UTC](https://discuss.prosemirror.net/t/why-emoijs-are-not-treated-as-one-index/6059 "2023-12-13T06:25:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mukhammadsaid19](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/mukhammadsaid19/32/2929_2.png) [@Mukhammadsaid19](https://discuss.prosemirror.net/u/Mukhammadsaid19)
#### Post date: [December 13, 2023, 6:25am UTC](https://discuss.prosemirror.net/t/why-emoijs-are-not-treated-as-one-index/6059/1 "2023-12-13T06:25:56Z")

</div>

I have been working on grammar checker in Prosemirror. The grammar checker backend is written in Golang and Python, with Golang part being responsible for slicing the changed parts of the document and Python being responsible for detecting highlights (suggestions). However, we discovered that Prosemirror treats emojis as two characters (two indices), while Python treats them as one. As a result, highlights get misaligned. Is there any hack around this?

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)
#### Post date: [December 13, 2023, 6:44am UTC](https://discuss.prosemirror.net/t/why-emoijs-are-not-treated-as-one-index/6059/2 "2023-12-13T06:44:58Z")

</div>

ProseMirror uses JavaScript’s string lengths, for efficiency and straightforward integration with the host platform. JavaScript strings are UTF16 based, meaning they use two string indices for ‘astral’ characters. This is a terrible system, but it’s what we’re stuck with in JavaScript land. You could write code that maps between this and per-character indices by iterating over the strings and adjusting for each astral character you find.

---

<div class="post-metadata">

### Author: ![Mukhammadsaid19](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/mukhammadsaid19/32/2929_2.png) [@Mukhammadsaid19](https://discuss.prosemirror.net/u/Mukhammadsaid19)
#### Post date: [December 13, 2023, 6:56am UTC](https://discuss.prosemirror.net/t/why-emoijs-are-not-treated-as-one-index/6059/3 "2023-12-13T06:56:58Z")

</div>

Hi, Marijn. I got it, I will share the hack here as soon as possible 🙃 . Thank you for quick response!
