4-character literal
Joel C. Salomon
JoelCSalomon at Gmail.com
Fri Jan 26 13:24:08 PST 2007
Rick Mann wrote:
> Joel C. Salomon Wrote:
>> Entering numbers in base 256 is asking for trouble, especially with UTF-8 source.
>
> I gotta say, I think they're very useful. Multibyte-character issues aside, it can be a lot handier to see 'abcd' in a debugger than '61626364'. And handling multibyte characters isn't that big a deal...just include all the bytes. If the integer interpretation is 4 bytes, treat it as an uint. If it's more, treat it as a ulong, and issue appropriate warnings/errors when assigning. Pad the values out with zeros. I'm not sure I understand the resistance to the notion.
Generally, though, arbitrary four bytes with the high bit set will
constitute an invalid UTF-8 sequence.
Assuming you have the number 61626364 in an int32 somewhere, will 'abcd'
really tell you something you wanted to know about the number? (Unless
you’re dereferencing a char* cast to int*, in which case you deserve all
the hassle the debugger can throw at you. ☺)
--Joel
More information about the Digitalmars-d
mailing list