add beg2char and char2end functions