简体   繁体   中英

'ß' character upper cased differently in SQL server and Python

I have an issue where this code is giving me an issue:

SELECT ID, UPPER(ItemDescription)
FROM ItemDescriptions
WHERE ItemDescription = 'ß'
ORDER BY ItemDescription

Now this query still returns 'ß'

In Python if I uppercase this character as such:

'ß'.upper()

This returns 'SS'.

The problem is when I have dictionary that contains a string with that character so it doesn't match when I pair the 2 up. Any pointers on this would be appreciated.

In the German language the ß is a character that only exists in lowercase since it is never found at the beginning of words.

This was leading to problems in typography if a word with an ß was capitalized.

To resolve this problem a capital ß has been introduced into Unicode as U+1E9E. In other codepages it is not available.

But this is only typographical, the official capitalization by Duden is SS, while in most recent editions do not disallow the use of the capital ß anymore. The DIN standard defines SS as the capitalization of ß.

So the result of Python's upper() is correct.

This is - to get to you actual question - one of the causes why you should use lower() instead of upper() to normalize strings before comparison.

Is there an upper case of ß? If there's not, why are you uppering it? Anyway, you can use regex to upper only characters in the range [a-zA-Z] , if it's outside of this range, you can just leave it as it be

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM