A General Approach to Uniformly Handle Different String Metrics Based on Heterogeneous Alphabets