gunichar *result,
gsize result_len);
+/**
+ * G_UNICHAR_MAX_COMPAT_DECOMPOSITION_LEN:
+ *
+ * The maximum length (in codepoints) of a compatibility or canonical
+ * decomposition of a single Unicode character.
+ *
+ * This is as defined by Unicode 6.1.
+ *
+ * Since: 2.31.3
+ */
+#define G_UNICHAR_MAX_DECOMPOSITION_LEN 18 /* codepoints */
+
/* Compute canonical ordering of a string in-place. This rearranges
decomposed characters in the string according to their combining
classes. See the Unicode manual for more information. */
* currently all decompositions are of length at most 4, but
* this may change in the future (very unlikely though).
* At any rate, Unicode does guarantee that a buffer of length
- * 18 is always enough for both compatibility and canonical
- * decompositions, so that is the size recommended.
+ * %G_UNICHAR_MAX_DECOMPOSITION_LEN is always enough for both compatibility and
+ * canonical decompositions, so that is the size recommended.
*
* See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
* for details.
* which could simplify this considerably.
*/
gsize decomp_len, i;
- gunichar decomp[18];
+ gunichar decomp[G_UNICHAR_MAX_DECOMPOSITION_LEN];
- decomp_len = g_unichar_fully_decompose (c, FALSE, decomp, 18);
+ decomp_len = g_unichar_fully_decompose (c, FALSE, decomp, G_N_ELEMENTS (decomp));
for (i=0; i < decomp_len; i++)
{
if (decomp[i] != 0x307 /* COMBINING DOT ABOVE */)