Embercode
✕
Character Arrays and StringsQuick quiz

Code points

6 questions. Covers Code points and emoji.

Questions 1 to 5 of 6

  1. 1. How many bytes does size() report for the grinning face U+1F600 stored in a std::string?
  2. 2. Which lead-byte pattern marks the start of a 2-byte UTF-8 character?
  3. 3. What does this program print? ``cpp #include <iostream> #include <string> int main() { std::string s = "na\U0001F600\U0001F600"; int code_points = 0; for (char c : s) { if ((static_cast<unsigned char>(c) & 0xC0) != 0x80) ++code_points; } std::cout << s.size() << " " << code_points << "\n"; } ``
  4. 4. What does this program print? ``cpp #include <format> #include <iostream> #include <string> int main() { std::string s = "\U0001F44D!"; std::cout << s.size() << " " << std::format("{:02X}", static_cast<unsigned char>(s[0])) << "\n"; } ``
  5. 5. True or false: every UTF-8 continuation byte starts with the bits 10, so (b & 0xC0) == 0x80 finds one.

5 question(s) left on this page.