Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #73730

Re: How to get a character consisting of multiple bytes into a string literal?

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: How to get a character consisting of multiple bytes into a string literal?
Date 2015-10-24 15:54 -0400
Organization Self
Message-ID <562BE20A.1040802@verizon.net> (permalink)
References <n0gehd$p8k$1@solani.org> <kfny4esdrhr.fsf@x-alumni2.alumni.caltech.edu> <n0gmcc$m10$2@solani.org>

Show all headers | View raw


On 10/24/2015 03:32 PM, Philipp Klaus Krause wrote:
> On 24.10.2015 20:57, Tim Rentsch wrote:
>> Philipp Klaus Krause <pkk@spth.de> writes:
>>
>>> So is it possible to create a string literal containing a multibyte
>>> character of more than one byte when the implementation supports only
>>> the basic source character set as source character set?
>>
>> Yes, it has been since C99:
>>
>>     #include <stdio.h>
>>
>>     int
>>     main(){
>>         char foo[] = "\u1234";
>>         printf( "sizeof foo = %zu\n", sizeof foo );
>>         return  0;
>>     }
>>
>> Running this on my system prints 'sizeof foo = 4'.

Does the compiler on your system "support only the basic character set",
as specified in the question? While universal character names (UCNs) can
be expressed without using any characters outside of that set, they're
not required to be meaningfully implemented.

> This looks like implementation-defined behaviour by verse 10 of section
> 6.4.4.4 of the C11 standard to me.
> What compiler did you use?

The "value ... is implementation-defined", not the behavior.
Note that the implementation-defined value need not be different for
UCNs. Since the target implementation is specified to be one that
"supports only the basic source character set", this is likely to be the
case - there's no reason for such an implementation to have CHAR_BIT >
8, no requirement that it support characters that are more than one byte
long, and there aren't enough distinct single-byte values to encode all
UCNs uniquely.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to get a character consisting of multiple bytes into a string literal? Philipp Klaus Krause <pkk@spth.de> - 2015-10-24 19:18 +0200
  Re: How to get a character consisting of multiple bytes into a string literal? James Kuyper <jameskuyper@verizon.net> - 2015-10-24 14:06 -0400
    Re: How to get a character consisting of multiple bytes into a string literal? Philipp Klaus Krause <pkk@spth.de> - 2015-10-24 20:39 +0200
      Re: How to get a character consisting of multiple bytes into a string literal? James Kuyper <jameskuyper@verizon.net> - 2015-10-24 15:05 -0400
  Re: How to get a character consisting of multiple bytes into a string literal? Richard Damon <Richard@Damon-Family.org> - 2015-10-24 14:07 -0400
    Re: How to get a character consisting of multiple bytes into a string literal? James Kuyper <jameskuyper@verizon.net> - 2015-10-24 14:33 -0400
    Re: How to get a character consisting of multiple bytes into a string literal? Philipp Klaus Krause <pkk@spth.de> - 2015-10-24 21:30 +0200
  Re: How to get a character consisting of multiple bytes into a string literal? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-24 11:11 -0700
    Re: How to get a character consisting of multiple bytes into a string literal? Keith Thompson <kst-u@mib.org> - 2015-10-24 13:44 -0700
  Re: How to get a character consisting of multiple bytes into a string literal? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-24 19:18 +0100
  Re: How to get a character consisting of multiple bytes into a string literal? Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-24 11:57 -0700
    Re: How to get a character consisting of multiple bytes into a string literal? Philipp Klaus Krause <pkk@spth.de> - 2015-10-24 21:32 +0200
      Re: How to get a character consisting of multiple bytes into a string literal? James Kuyper <jameskuyper@verizon.net> - 2015-10-24 15:54 -0400
      Re: How to get a character consisting of multiple bytes into a string literal? Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-24 14:43 -0700
        Re: How to get a character consisting of multiple bytes into a string literal? Philipp Klaus Krause <pkk@spth.de> - 2015-10-25 10:38 +0100
          Re: How to get a character consisting of multiple bytes into a string literal? Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-25 10:05 -0700

csiph-web