History

Better handling of UCNs in strings

As the standard requires, take 4 hex digits after the \u opener of a Universal Character Name, or take 8 hex digits after \U, but reject smaller counts and don't consume more (https://port70.net/~nsz/c/c11/n1570.html#6.4.3, https://port70.net/~nsz/c/c99/n1256.html#6.4.3). The unicode codepoint used to get truncated to 1 byte. Now it gets expanded into UTF-8, matching gcc & clang behavior on Linux.

Petr Skocik committed 5 years ago

Commit ffb95c21 parent 6b614c42 files · +46 −7Browse files

Showing the changes to tests (1 of 2 files). Show all

Unified · Split

tests/tests2/97_utf8_string_literal.c+8−1
@@ -1,12 +1,19 @@
11 // this file contains BMP chars encoded in UTF-8
22 #include <stdio.h>
33 #include <wchar.h>
4+#include <stdlib.h>
5+#include <string.h>
46
57 int main()
68 {
9+ char hello_world_in_czech[] = "čau, světe";
10+ char hello_world_in_czech_ucn[] = "\u010dau, sv\u011bte";
11+ if (sizeof(hello_world_in_czech) != sizeof(hello_world_in_czech_ucn)
12+ || strcmp(hello_world_in_czech, hello_world_in_czech_ucn))
13+ abort();
14+
715 wchar_t s[] = L"hello$$你好¢¢世界€€world";
816 wchar_t *p;
917 for (p = s; *p; p++) printf("%04X ", (unsigned) *p);
10− printf("\n");
1118 return 0;
1219 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t