ToUpper的() [英] ToUpper()

查看:81
本文介绍了ToUpper的()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在尝试将字符串转换为没有重音符号的字符串。目前,

ToUpper将é转换为带有重音的E ......

我试图建立英语文化(en)但它是一样的.. 。


有什么想法吗?


Ornette。

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.

推荐答案

好的,最后我这样做了:


private string ReplaceAccents(string chaine)

{


string strAccents =

"àá????àa???? ???????????????????????????????????????? ü? ????" ;;

string strNoAccents =

" AAAAAAaaaaaaOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuuu NnCc";


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()) ;

}

返回chaine;

}


J''aspastrouvémieux, mêmesi?a boucle un peu pour rien ...


Ornette。

" Ornette" < abstrait ... nospam ... @free.fraécritdansle message de

news:DF ******************** ************** @ microsof t.com ...
Ok, finally I did it like this :

private string ReplaceAccents(string chaine)
{

string strAccents=
"àá????àáa???òó????òó????èéê?èéê?ìí??ìí??ùú?üùú?ü? ????";
string strNoAccents =
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuy NnCc";

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...@free.fra écrit dans le message de
news:DF**********************************@microsof t.com...

你好,


我正在尝试将字符串转换为没有重音符号的字母。对于

的时刻,ToUpper将é转换为带有重音的E ......

我试图设置英语文化(en)但它是一样的.. 。


有什么想法吗?


Ornette。
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.


你好,


这样更好:


byte [] bString =

System.Text.Encoding.GetEncoding(1251).GetBytes(St ringAvecAccents);

string stringSansAccent = System.Text.Encoding.ASCII.GetString( bString);


参考代码页:
http://www.microsoft.com/globaldev/r...sbcs/1251.mspx


Ornette。


" Ornette" < abstrait ... nospam ... @free.fraécritdansle message de

news:56 ******************** ************** @ microsof t.com ...
Hello,

This is better :

byte[] bString =
System.Text.Encoding.GetEncoding(1251).GetBytes(St ringAvecAccents);
string stringSansAccent = System.Text.Encoding.ASCII.GetString(bString );

Reference CodePage :
http://www.microsoft.com/globaldev/r...sbcs/1251.mspx

Ornette.

"Ornette" <abstrait...nospam...@free.fra écrit dans le message de
news:56**********************************@microsof t.com...

好​​的,最后我这样做了:


private string ReplaceAccents(string chaine)

{


string strAccents =

" AA ???? AAA ??? OO ???? OO ???? EEE?EEE?II ?? II ?? UU?UUU?ü? ????" ;;

string strNoAccents =

" AAAAAAaaaaaaOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuuu NnCc";


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()) ;

}

返回chaine;

}


J''aspastrouvémieux, mêmesi?a boucle un peu pour rien ...


Ornette。

" Ornette" < abstrait ... nospam ... @free.fraécritdansle message de

news:DF ******************** ************** @ microsof t.com ...
Ok, finally I did it like this :

private string ReplaceAccents(string chaine)
{

string strAccents=
"àá????àáa???òó????òó????èéê?èéê?ìí??ìí??ùú?üùú?ü? ????";
string strNoAccents =
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuy NnCc";

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...@free.fra écrit dans le message de
news:DF**********************************@microsof t.com...

>你好,

我正在尝试将字符串转换为没有重音的上部。对于
时刻,ToUpper将é转换为带有重音的E ......
我试图建立英语文化(en),但它是一样的......
有什么想法吗?

Ornette。
>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.


Ornette< abstrait ... nospam ... @ free.frwrote:
Ornette <abstrait...nospam...@free.frwrote:

这是更好的:


byte [] bString =

System.Text.Encoding.GetEncoding(1251).GetBytes(St ringAvecAccents) ;

string stringSansAccent = System.Text.Encoding.ASCII.GetString(bString);
This is better :

byte[] bString =
System.Text.Encoding.GetEncoding(1251).GetBytes(St ringAvecAccents);
string stringSansAccent = System.Text.Encoding.ASCII.GetString(bString );



嗯,这是假设编码会找到最接近的匹配

字母。它可能现在可以使用,但不能保证它将在

的未来。


-

Jon Skeet - < sk *** @ pobox.com>
http:// www.pobox.com/~skeet 博客: http:// www。 msmvps.com/jon.skeet

如果回复该群组,请不要给我发邮件

Well, that''s assuming that the encoding will find the closest match
letter. It may work now, but there''s no guarantee that it will in the
future.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


这篇关于ToUpper的()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆