Groups | Search | Server Info | Login | Register


Groups > comp.lang.c++.moderated > #7404

Re: utf-8 string literal

Message-ID <1dddbe96-bfd4-40ca-b20e-777347977faa@googlegroups.com> (permalink)
Newsgroups comp.lang.c++.moderated
From Öö Tiib <ootiib@hot.ee>
Subject Re: utf-8 string literal
Organization unknown
References <4451918c-67a9-41aa-bf05-4e3d093067d3@googlegroups.com>
Date 2016-03-14 17:10 -0600

Show all headers | View raw


On Monday, 14 March 2016 13:50:14 UTC+2, Sascha Schwarz  wrote:
> Recently we were discussing if the following snippet is guaranteed to
> compiles on all conforming platforms.
> 
> int main() {
> 	// wikipedia's example from https://en.wikipedia.org/wiki/UTF-8
> 	constexpr const char euro[] = u8"\u20ac";
> 	static_assert(
> 	       sizeof euro == 4
> 	       && euro[0] == static_cast<const char>(0b11100010)
> 	       && euro[1] == static_cast<const char>(0b10000010)
> 	       && euro[2] == static_cast<const char>(0b10101100),
> 	       "Not utf-8.");
> }
> 
> Looking at 2.3 (Basic charset) and 2.14.5 (String literals) we _think_
> so, but are not sure.

Can you elaborate what makes you unsure?


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

Back to comp.lang.c++.moderated | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

utf-8 string literal Sascha Schwarz <s4as5z@googlemail.com> - 2016-03-14 06:49 -0600
  Re: utf-8 string literal Öö Tiib <ootiib@hot.ee> - 2016-03-14 17:10 -0600
    Re: utf-8 string literal Sascha Schwarz <s4as5z@googlemail.com> - 2016-03-15 08:45 -0600

csiph-web