T-duality in arbitrary string backgrounds