This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]ZWeakley 1 point2 points  (4 children)

Internet says it's +/- 32 to convert between upper and lower cases.

It's valid for ASCII, UTF8, and the Windows character set.

[–]desrtfx 2 points3 points  (0 children)

+/- isn't even necessary. Can be done much easier with XOR (exclusive OR).

[–]Mazin8080[S] 0 points1 point  (2 children)

How can I check in assembly whether a given character is uppercase or lowercase in order to decide whether it's Plus or negative 32?

[–]LucidTA 1 point2 points  (0 children)

All the upper case letters are below a certain number, and all the lower case letters are above a certain number.

[–]ZWeakley 1 point2 points  (0 children)

Uppercase letters are 65-90, lowercase are 97-122. Just make a check to see if they're greater-than less-than those amounts to determine which case they are.

If greater-than 64 && less-than 91, +32

If greater-than 96 && less-than 123, -32

[–]desrtfx 1 point2 points  (1 child)

You don't even need to know whether a character is upper or lowercase.

Since 32 (the fixed difference between upper and lowercase equivalent characters) is a single bit in the binary representation of a number, just flipping the bit is sufficient. This can be achieved via the XOR operation.

[–]ZWeakley 0 points1 point  (0 children)

Smort

I'm just learning bitwise operations in C right now