Moved NSAttachmentCharacter replacement code inwards such that the NSString is only created when needed