Note: The programmer who passes an UTF-8 encoded string to
gettext() or similar API functions will have to have called
bind_textdomain_codeset (DOMAIN, "UTF-8") first. */
- if (bufpos == 2 && buffer[0] == 'u' && buffer[1] == '8')
+ if ((bufpos == 1
+ && (buffer[0] == 'u' || buffer[0] == 'U'
+ || buffer[0] == 'L'))
+ || (bufpos == 2 && buffer[0] == 'u' && buffer[1] == '8'))
goto string_literal;
/* Recognize C++11 raw string literals.
See ISO C++ 11 section 2.14.5 [lex.string].
&& buffer[bufpos - 1] == 'R')
{
/* Only R and u8R raw strings can be used as gettext()
- arguments, for type reasons. */
- const bool relevant = (bufpos != 2);
+ arguments, for type reasons. But the programmer may have
+ defined
+ - a c16gettext function that takes a 'const char16_t *'
+ argument, or
+ - a c32gettext function that takes a 'const char32_t *'
+ argument, or
+ - a wgettext function that takes a 'const wchar_t *'
+ argument. */
int starting_line_number = line_number;
bufpos = 0;
/* Start the buffer with a closing parenthesis. This makes the
int state;
/* Start accumulating the string. */
- if (relevant)
- mixed_string_buffer_init (&msb, lc_string,
- logical_file_name,
- line_number);
+ mixed_string_buffer_init (&msb, lc_string,
+ logical_file_name, line_number);
state = 0;
for (;;)
c = phase3_getc ();
/* Keep line_number in sync. */
- if (relevant)
- msb.line_number = line_number;
+ msb.line_number = line_number;
if (c == EOF)
break;
else /* state == bufpos && c == '"' */
{
/* Finished parsing the string. */
- if (relevant)
- {
- tp->type = token_type_string_literal;
- tp->mixed_string = mixed_string_buffer_result (&msb);
- tp->comment = add_reference (savable_comment);
- }
- else
- tp->type = token_type_symbol;
+ tp->type = token_type_string_literal;
+ tp->mixed_string = mixed_string_buffer_result (&msb);
+ tp->comment = add_reference (savable_comment);
return;
}
}
/* None of the bytes buffer[0]...buffer[state-1]
can be ')'. */
- if (relevant)
- for (i = 0; i < state; i++)
- mixed_string_buffer_append_char (&msb, buffer[i]);
+ for (i = 0; i < state; i++)
+ mixed_string_buffer_append_char (&msb, buffer[i]);
/* But c may be ')'. */
if (c == ')')
state = 1;
else
{
- if (relevant)
- mixed_string_buffer_append_char (&msb, c);
+ mixed_string_buffer_append_char (&msb, c);
state = 0;
}
}
cat <<\EOF > xg-c-5.c
gettext("Choose a " u8"rosé wine à la carte");
+/* Some people may define a gettext-like function that takes a 'const wchar_t *' argument. */
+wgettext(L"Pulp " L"Fiction");
+/* Or a gettext-like function that takes a 'const char16_t *' argument. */
+c16gettext (u"Rain " u"Man");
+/* Or a gettext-like function that takes a 'const char32_t *' argument. */
+c32gettext (U"Jurassic " U"Park");
EOF
${XGETTEXT} --from-code=ISO-8859-1 --no-location \
+ -kgettext -kwgettext -kc16gettext -kc32gettext \
-o xg-c-5.tmp xg-c-5.c || Exit 1
func_filter_POT_Creation_Date xg-c-5.tmp xg-c-5.po
msgid "Choose a rosé wine à la carte"
msgstr ""
+
+msgid "Pulp Fiction"
+msgstr ""
+
+msgid "Rain Man"
+msgstr ""
+
+msgid "Jurassic Park"
+msgstr ""
EOF
: ${DIFF=diff}
gettext (u8"This is a UTF-8 string");
+wgettext (L"This is a wide string");
+
+c16gettext (u"This is a 16-bit wide char string");
+
+c32gettext (U"This is a 32-bit wide char string");
+
u88"This is not a UTF-8 string";
u"This is a UTF-16 string";
EOF
${XGETTEXT} --add-comments --no-location --no-wrap \
+ -kgettext -kwgettext -kc16gettext -kc32gettext \
-o xg-c-c++-1.tmp xg-c-c++-1.cc || Exit 1
func_filter_POT_Creation_Date xg-c-c++-1.tmp xg-c-c++-1.po
msgid "This is a UTF-8 string"
msgstr ""
+msgid "This is a wide string"
+msgstr ""
+
+msgid "This is a 16-bit wide char string"
+msgstr ""
+
+msgid "This is a 32-bit wide char string"
+msgstr ""
+
msgid ""
"\n"
"This is a raw string\n"