tangled
alpha
login
or
join now
ansxor.ca
/
witchsky.app
forked from
jollywhoppers.com/witchsky.app
1
fork
atom
Bluesky app fork with some witchin' additions 💫
1
fork
atom
overview
issues
pulls
pipelines
forgot this file!!
authored by
12Me21
and committed by
ansxor.ca
2 weeks ago
040314ea
d2a16fd2
+13
1 changed file
expand all
collapse all
unified
split
src
lib
twelve
byteindex.js
+13
src/lib/twelve/byteindex.js
···
1
1
+
function string_to_bytes(string) {
2
2
+
return unescape(encodeURIComponent(string))
3
3
+
}
4
4
+
function bytes_to_string(string) {
5
5
+
return decodeURIComponent(escape(string))
6
6
+
}
7
7
+
// note: we always work with native strings in our code
8
8
+
export function index_to_byteindex(string, index) {
9
9
+
return string_to_bytes(string.slice(0, index)).length
10
10
+
}
11
11
+
export function byteindex_to_index(string, byteindex) {
12
12
+
return bytes_to_string(string_to_bytes(string).slice(0, byteindex)).length
13
13
+
}