Re: ToUpper() Better solution



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@xxxxxxxxxxxxxxxx
Hello,

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.


.



Relevant Pages

  • Re: Limits to the Switch Fonction
    ... Option Compare Database ... Function Equivalence(StudentType As String) As String ... Equivalence = "Belgique" ... "Jeff Boyce" a écrit dans le message de ...
    (microsoft.public.access.reports)
  • Re: finding duplicated files
    ... "foxidrive" a écrit dans le message de ... 273 "C:\Users\Jean\Desktop\Acrobat User Community Forums.url" ... b- How can I use a for loop to output the first part of the string and after the second part of the string using the space as a delimiter. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Datatable.select correct syntax
    ... Year is a string. ... dans le message de news: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Removing Spaces from string
    ... dans le message de news: ... I want to be able to remove spaces from a string, ... muiltiple words to create a string with no spaces. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: ToUpper()
    ... private string ReplaceAccents(string chaine) ... string strNoAccents = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNnCc"; ...
    (microsoft.public.dotnet.general)

Loading