Smart string truncation