(CFACT-91) Use assign of a range instead of substr

Avoids losing the internal buffer in output by doing move assignment
from the substr result. Potentially saves some memory allocations.