MAINT: Extract a helper function from StringConverter
MAINT: Extract a helper function from StringConverter

The previous logic here was very hard to follow, as loop variables were being used after the loop ended, and being conditionally overwritten.

jakirkham/numpy,mattip/numpy,mhvk/numpy,seberg/numpy,mhvk/numpy,madphysicist/numpy,mattip/numpy,simongibbons/numpy,madphysicist/numpy,endolith/numpy,pbrod/numpy,numpy/numpy,abalkin/numpy,numpy/numpy,charris/numpy,mattip/numpy,pbrod/numpy,pdebuyl/numpy,pdebuyl/numpy,seberg/numpy,simongibbons/numpy,grlee77/numpy,pbrod/numpy,pbrod/numpy,jakirkham/numpy,madphysicist/numpy,jakirkham/numpy,simongibbons/numpy,jakirkham/numpy,simongibbons/numpy,rgommers/numpy,mhvk/numpy,seberg/numpy,pdebuyl/numpy,seberg/numpy,pbrod/numpy,endolith/numpy,charris/numpy,anntzer/numpy,pdebuyl/numpy,charris/numpy,grlee77/numpy,anntzer/numpy,madphysicist/numpy,endolith/numpy,grlee77/numpy,numpy/numpy,numpy/numpy,mhvk/numpy,rgommers/numpy,anntzer/numpy,endolith/numpy,charris/numpy,anntzer/numpy,mattip/numpy,madphysicist/numpy,abalkin/numpy,simongibbons/numpy,jakirkham/numpy,grlee77/numpy,grlee77/numpy,rgommers/numpy,mhvk/numpy,abalkin/numpy,rgommers/numpy