Should you be able to initialize a float with a char?

Ali Çehreli acehreli at yahoo.com
Thu May 19 20:48:47 UTC 2022


On 5/19/22 12:13, kdevel wrote:
 > On Thursday, 19 May 2022 at 18:35:42 UTC, Walter Bright wrote:
 >> On 5/19/2022 1:05 AM, bauss wrote:
 >>> On Thursday, 19 May 2022 at 04:10:04 UTC, Walter Bright wrote:
 >>>>
 >>>> There's nothing wrong with:
 >>>>
 >>>>     if ('A' <= c && c <= 'Z')
 >>>>         c = c | 0x20;
 >>>>
 >>>
 >>> There is, this assumes that the character is ascii and not unicode.
 >>
 >> It does not assume it, it tests for if it would be valid.
 >
 > "However, the assumption that setting bit 5 of the representation will
 > convert uppercase letters to lowercase is not valid for EBCDIC." [1]
 >
 > [1] Does C and C++ guarantee the ASCII of [a-f] and [A-F] characters?
 >      https://ogeek.cn/qa/?qa=669486/

In D, char is UTF-8 and ASCII is a subset of UTF-8. Walter's code above 
is valid without making any ASCII assumption.

Ali



More information about the Digitalmars-d mailing list