Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
307 views
in Technique[技术] by (71.8m points)

c# - Why is "ss" equal to the German sharp-s character 'ß'?

Coming from this question I'm wondering why ? and ae are different(which makes sense) but ? and ss are treated as equal. I haven't found an answer on SO even if this question seems to be related and even mentions "that ? will compare equal to SS in Germany, or similar" but not why.

The only resource on MSDN I found was this: How to: Compare Strings

Here is mentioned following but also lacks the why:

// "They dance in the street." 
// Linguistically (in Windows), "ss" is equal to 
// the German essetz: '?' character in both en-US and de-DE cultures. 
.....

So why does this evaluate to true, both with de-DE culture or any other culture:

var ci = new CultureInfo("de-DE");
int result = ci.CompareInfo.Compare("strasse", "stra?e", CompareOptions.IgnoreNonSpace); // 0
bool equals = String.Equals("strasse", "stra?e", StringComparison.CurrentCulture); // true
equals = String.Equals("strasse", "stra?e", StringComparison.InvariantCulture);  // true
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you look at the ? page, you'll see that not always ? is a replacement for ? (or ae), and it is still used in various languages.

The letter ? instead:

While the letter "?" has been used in other languages, it is now only used in German. However, it is not used in Switzerland, Liechtenstein or Namibia.[1] German speakers in Germany, Austria, Belgium,[2] Denmark,[3] Luxembourg[4] and South Tyrol, Italy[5] follow the standard rules for ?.

So the ? is used in a single language, with a single rule (? == ss), while the ? is used in multiple languages with multiple rules.

Note that, considering that case folding is:

Case folding is primarily used for caseless comparison of text, such as identifiers in a computer program, rather than actual text transformation

The official Unicode 7.0 Case Folding Properties tells us that

00DF; F; 0073 0073; # LATIN SMALL LETTER SHARP S

where 00DF is ? and 0073 is s, so ? can be considered, for caseless comparison, as ss.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...