fix broken tables caused by incorrectly calculated unicode string length

Counting the number of characters in unicode strings is [hard](https://mathiasbynens.be/notes/javascript-unicode). This sould fix problems with astral symbols and combining marks (e.g. diacritics).