Re: ToUpper() Better solution
- From: "Ornette" <abstrait...nospam...@xxxxxxx>
- Date: Thu, 1 Mar 2007 03:03:04 +0100
Hello,
This is better :
byte[] bString = System.Text.Encoding.GetEncoding(1251).GetBytes(StringAvecAccents);
string stringSansAccent = System.Text.Encoding.ASCII.GetString(bString );
Reference CodePage : http://www.microsoft.com/globaldev/reference/sbcs/1251.mspx
Ornette.
"Ornette" <abstrait...nospam...@xxxxxxx> a écrit dans le message de news:56DD78D4-70EC-454B-8587-32D95BE57F65@xxxxxxxxxxxxxxxx
Ok, finally I did it like this :
private string ReplaceAccents(string chaine)
{
string strAccents= "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÌÍÎÏìíîïÙÚÛÜùúûüÿÑñÇç";
string strNoAccents = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNnCc";
char[] tAccent = strAccents.ToCharArray();
char[] tNoAccent = strNoAccents .ToCharArray();
for(int i=0; i<strAccents.Length; i++)
{
chaine = chaine.Replace(tAccent [i].ToString(), tNoAccent [i].ToString());
}
return chaine;
}
J'ai pas trouvé mieux, même si ça boucle un peu pour rien...
Ornette.
"Ornette" <abstrait...nospam...@xxxxxxx> a écrit dans le message de news:DF19D390-EC69-42DF-B4F9-8B9C5355ADEC@xxxxxxxxxxxxxxxxHello,
I'm trying to convert strings to upper without the accents. For the moment, ToUpper converts é to E with an accent...
I tried to set up english culture (en) but it's the same...
Any ideas ?
Ornette.
.
- Follow-Ups:
- Re: ToUpper() Better solution
- From: Jon Skeet [C# MVP]
- Re: ToUpper() Better solution
- References:
- ToUpper()
- From: Ornette
- Re: ToUpper()
- From: Ornette
- ToUpper()
- Prev by Date: Re: ToUpper()
- Next by Date: Re: DVD writer not working
- Previous by thread: Re: ToUpper()
- Next by thread: Re: ToUpper() Better solution
- Index(es):
Relevant Pages
|
Loading