« first day (279 days earlier)      last day (4676 days later) » 

11:00 PM
Your source code file comes in some encoding
 
> A string literal is a sequence of characters (as defined in 2.14.3)
It's like a treasure hunt!
 
(I'm not even sure what the C standard says about that; I'm pretty sure it does not mandate an encoding!)
More like a wild goose chase :-)
 
> An ordinary character literal that contains a single c-char has type char, with value equal to the numerical value of the encoding of the c-char in the execution character set.
Covers narrow literals.
 
So return is a keyword, but not 72 65 74 75 72 6E.
 
See ?
execution character set
Encoding
 
11:01 PM
Yes. That's arbitrary.
(GCC says -fexec-charset.)
 
> A character literal that begins with the letter u, such as u’y’, is a character literal of type char16_t. The value of a char16_t literal containing a single c-char is equal to its ISO 10646 code point value, provided that the code point is representable with a single 16-bit code unit.
 
OK, no problem
 
Can you make sense of that?
Oh okay.
How odd.
 
Yeah. u'a' is OK and u'\U000000F6' is, too, but u'\U0010FFFF' is not
Neither is u'\uDB00' but for different reasons.
 
I went back to string literals
 
11:04 PM
What we don't know is the value of u'y'.
 
> Ordinary string literals and UTF-8 string literals are also referred to as narrow string literals. A narrow string literal has type “array of n const char”, where n is the size of the string as defined below, and has static storage duration
That's odd isn't it?
@KerrekSB "The value of a char16_t literal containing a single c-char is equal to its ISO 10646 code point value"
 
By contrast, I do know the value of u'\u0079', and it's semantics (small letter y).
Why is that odd?
All that is fine
 
The value is the code point-value of the value?
@KerrekSB I wouldn't have referred to utf-8 as narrow string.
 
Sure. The value of char16_t x = 0xE000 is 0xE000 as a number, but interpreted as a Unicode codepoint it is U+E000.
 
Good point.
 
11:06 PM
@LucDanton Its code unit is one byte, so that's narrow
It's multi-byte narrow
Since we're now dealing with codepoints via \u/\U, this correspondence is important to clarify.
You should post our findings as an answer :-)
But we still don't know why one would need u8.
 
I can't think of any other interpretation other than e.g. U'y' == static_cast<long long>('y') (ignoring any issue with integral conversion there could be). That is to say, that [u8|u|U]'y' is always the value of the encoding of the execution set, and that it is equal to 'y'.
 
Finally, I have no idea if there are any new string handling functions (or even just string types!).
 
@KerrekSB No not really. You can't even output them to a standard stream.
 
So if y was encoded as 0x7F in our encoding, then U'y' would be 0x0000007F?
Right
But at least something like string length or so...
 
That one would not be a trivial function.
 
11:11 PM
No
 
Specifying e.g. <unicode> would not be an easy undertaking (and I don't think anybody really cares).
 
Hm, I'm worried now about U'y'. It wouldn't make sense if the value of that depended on the platform, but the opposite wouldn't make sense either.
It's plainly possible for the compiler to convert from platform to UTF-*, but that would break compatibility with ordinary chars.
 
Do you mean you expect 'y' == U'y' to hold?
 
If you're reading a y from a file, you want it to compare equal to y.
Yeah
 
how ugly.
 
11:14 PM
Quite
 
I'd rather not have that.
 
OK, one could try this with GCC and change the exec charset
 
Heh
 
Looking for a character that's differently encoded in ASCII and EBCDIC
 
Most of them I'd wager.
 
11:24 PM
Hm, that's a total disaster. Now all the output is garbled
Oh wait, I can pipe it through iconv
Ahh, it broke all the printf format specifiers! :-)
Take that, printf
my libc isn't compatible with EBCDIC
 
You'd need a locale for it, wouldn't you?
 
Shall I transpose my entire program to iostreams?
 
... or recompile libc with the same flag.
 
I don't think it's a matter of locale. It's about matching %
Yes
 
Well, you need to encode the printf string then
Even simpler
 
11:27 PM
Damn it. With iostreams, the program will take up three times as much source code
 
E.g. write/find a program to make it in \xXX form
 
Yes
Nice
Hm, nah, too much looking up and typing. Iomanip it is
 
Hah, got it!
char X[] = "abc", Y[] = u8"abc";
Y is now 61 62 63 00, and X is 81 82 83 00!!
So u8 does perform conversion from the exec-cs to UTF8!
 
Well, that's not the surprising part tbh.
The surprising part is how and where the Standard specifies it.
 
11:43 PM
Hm, it's mildly surprising, non? Because an explicit conversion is taking place
 
Not a conversion no. Perhaps a translation.
 
What's the difference?
Oh, apparently there are user-definable literal modifiers in C++0x. operator "".
 
@KerrekSB Terminology. E.g. char c = 10; involves a conversion.
 
(Phew, I got an answer accepted before the day's out.)
Oh OK, you want to reserve "conversion" for types.
So we should rename iconv to itrans?
 
Are you saying that iconv is used at the compile or runtime phases of a C++ program? I think you'll find that you're mistaken.
> 2.2 Phases of translation
That the relevant bit.
Not types.
Hey that's where the answer to our surprises is.
> 5. Each source character set member in a character literal or a string literal, as well as each escape sequence and universal-character-name in a character literal or a non-raw string literal, is converted to the corresponding member of the execution character set (2.14.3, 2.14.5); if there is no corresponding member, it is converted to an implementation-defined member other than the null (wide) character.
Or is it?
Going to check what 'corresponding member' means.
 
11:51 PM
Iconv is only used at compile time.
But it's called i-**conv** :-)
 
You completely missed the point.
 
Where's that from? Because it clearly does not happen for unmarked literals "".
What was the point? What's conversion and what's translation?
 
I want to call it a translation because such things happen during the translation phase.
It has nothing to do with type conversion.
 
Got it, I see.
Yeah, that makes sense.
Never mind, it's not like all those terms aren't horribly overloaded already :-)
(I got 40 dead excess upvotes :-) I wish they did cap-free Fridays!)
 
@KerrekSB Doesn't a narrow set literal end up as EBCDIC with the approriate flag?
 
11:56 PM
With -fexec-charset=EBCDIC-UK, "abc" becomes 81 82 83 00, yes.
but u8"abc" is UTF8
Please do feel free to post all this as an answer, I'll gladly accept it!
 

« first day (279 days earlier)      last day (4676 days later) »