开发者

C#- ToLower() is sometimes removing dot from the letter "I"

开发者 https://www.devze.com 2023-03-17 14:22 出处:网络
We have noticed a weird error when calling ToLower() on certain strings. The input string is: string s = \"DocumentInfo\";

We have noticed a weird error when calling ToLower() on certain strings.

The input string is:

string s = "DocumentInfo";
string t = s.ToLower();
// sometimes, t == documentinfo
// other times, t == documentınfo  (note dot is missing from i - INCORRECT)

We are passing the string to a web service query downstream, so it is causing problems for us.

My initial guess is that it has something to do with Culture or开发者_如何学Python UICulture, as some of our pages customize these settings per user.

Could this be the issue? Is there are way I can force this to work properly?

UPDATE 2011.07.06

I found that I could duplicate the issue by setting Culture to tr-TR. Not sure if other cultures are impacted.


Try using String.ToLowerInvariant().


Try :

s.ToLower(new CultureInfo("en-US", false));

If you get a different result, your CultureInfo.CurrentCulture may be set to something else.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号