forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1function string_to_bytes(string) {
2 return unescape(encodeURIComponent(string))
3}
4function bytes_to_string(string) {
5 return decodeURIComponent(escape(string))
6}
7// note: we always work with native strings in our code
8export function index_to_byteindex(string, index) {
9 return string_to_bytes(string.slice(0, index)).length
10}
11export function byteindex_to_index(string, byteindex) {
12 return bytes_to_string(string_to_bytes(string).slice(0, byteindex)).length
13}