Safer string conversion