串StartsWith()问题与丹麦文本 [英] String StartsWith() issue with Danish text

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

问题描述

任何人都可以解释这种现象。

Can anyone explain this behaviour?

var culture = new CultureInfo("da-DK");
Thread.CurrentThread.CurrentCulture = culture;
"daab".StartsWith("da"); //false



我知道,它可以通过指定固定 StringComparison.InvariantCulture 。但我只是行为混淆。

I know that it can be fixed by specifying StringComparison.InvariantCulture. But I'm just confused by the behavior.

我也知道,AA和AA不被视为在丹麦不区分大小写的比较一样,见 http://msdn.microsoft.com/en-us/library/xk2wykcz.aspx 。这也解释了这个

I also know that "aA" and "AA" are not considered the same in a Danish case-insensitive comparision, see http://msdn.microsoft.com/en-us/library/xk2wykcz.aspx. Which explains this

String.Compare("aA", "AA", new CultureInfo("da-DK"), CompareOptions.IgnoreCase) // -1 (not equal)

时此链接到第一代码的行为段?

Is this linked to the behavior of the first code snippet?

推荐答案

如尿布称,其在丹麦的语言,其中AA和A仍然是一个特点相同。丹麦得到了另外两个字母,AE和ø,但我不知道他们是否可以使用两个字母也被写入。

Like Nappy said, its a feature of the danish language, where "aa" and "å" is still the same. Danish got another two letters, æ and ø, but I am not sure if they can be written using two letters as well.

我认为在第二个例子中AA而AA被改变为A是不改变。只是为了更迷惑的事情,AA被认为等于AA和AA只用不区分大小写的比较时。

I think in the second example "aA" is not changed while "AA" is changed to "Å". Just to confuse things even more, "Aa" is considered equal to "AA" and "aa" only when using case-insensitive comparing.

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

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