copied from original str2str