serialize: ref #12697 minor adj. to last char check + prettyencode test