Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

upperCase function without french accents (See related posts)

/// <summary>
/// Returns a copy of a string in uppercase, without accents
/// </summary>
/// <param name="text">Valid string expression</param>
/// <returns>String converted to uppercase</returns>
public static string upperCase (string text) {
	const string accents = "�ÀÄÂÉÈËÊ�Ì�ÎÓÒÖÔÚÙÜÛŸÇ";
	const string normaux = "AAAAEEEEIIIIOOOOUUUUYC";
	string majuscules = text.ToUpper();
	for (int i = 0; i < accents.Length; i++) {
		majuscules = majuscules.Replace(accents.Substring(i, 1), normaux.Substring(i, 1));
	}
	majuscules = majuscules.Replace("Æ", "AE");
	majuscules = majuscules.Replace("Å’", "OE");
	return majuscules;
}

And:
/// <summary>
/// Returns a copy of a string in lowercase, without accents
/// </summary>
/// <param name="text">Valid string expression</param>
/// <returns>String converted to lowercase</returns>
public static string lowerCase (string text) {
	return upperCase(text).ToLower();
}

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts