In principle you already know the length here. So either have wide_to_utf8 return a length param, or merge these two functions.
wide_to_utf8 is used independently of populate_xml_string in later (as of yet unsubmitted) patches. While I could merge them now, it seems a bit counterproductive to then have to unmerge them later. I'll add a length return parameter as suggested.
Thanks,
Owen