I want to find a line number and a column for a particular byte number in a buffer in Neovim. I can get it (sort of) with
local b = 444
local line = vim.fn.byte2line(b)
local line_start = vim.fn.line2byte(line)
local col = b - line_start + 1
But the result will not be correct for multibyte charactes.
How to calculate line and column correctly for a given byte in a buffer?