Editors think of code as a grid, but behind the scenes, it is just a flat
array of UTF-16 characters. getOffset tells you your index in that
flat array. So if you chomp "\n\n\n\n" you are on row 5, column 1,
and offset 4.
Note: JavaScript uses a somewhat odd version of UTF-16 strings,
so a single character may take two slots. So in JavaScript, 'abc'.length === 3`` but '🙈🙉🙊'.length === 6`. Try it out!
Editors think of code as a grid, but behind the scenes, it is just a flat array of UTF-16 characters.
getOffset
tells you your index in that flat array. So if you chomp"\n\n\n\n"
you are on row 5, column 1, and offset 4.Note: JavaScript uses a somewhat odd version of UTF-16 strings, so a single character may take two slots. So in JavaScript,
'abc'.length === 3`` but
'🙈🙉🙊'.length === 6`. Try it out!