utilities to convery between line numbers and character numbers