summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bdb4a63)
Unicode decomposition and normalization are now implemented.
+#include <string.h>
+#include <glib.h>
g_return_val_if_fail(buf != NULL && (len > 0 || numchars > 0), 0);
g_return_val_if_fail(numchars <= len, 0);
g_return_val_if_fail(buf != NULL && (len > 0 || numchars > 0), 0);
g_return_val_if_fail(numchars <= len, 0);
- /* TODO: Implement this */
- return numchars;
+ long outchars;
+
+ /* Normalize the string */
+ char *utf8 = convert_ucs4_to_utf8(buf, numchars);
+ if(!utf8)
+ return numchars;
+ char *decomposed = g_utf8_normalize(utf8, -1, G_NORMALIZE_NFD);
+ g_free(utf8);
+ gunichar *outbuf = convert_utf8_to_ucs4(decomposed, &outchars);
+ g_free(decomposed);
+ if(!outbuf)
+ return numchars;
+
+ /* Copy the output buffer to the original buffer */
+ memcpy(buf, outbuf, MIN(outchars, len) * 4);
+ g_free(outbuf);
+
+ return outchars;
g_return_val_if_fail(buf != NULL && (len > 0 || numchars > 0), 0);
g_return_val_if_fail(numchars <= len, 0);
g_return_val_if_fail(buf != NULL && (len > 0 || numchars > 0), 0);
g_return_val_if_fail(numchars <= len, 0);
- /* TODO: Implement this */
- return numchars;
+ long outchars;
+
+ /* Normalize the string */
+ char *utf8 = convert_ucs4_to_utf8(buf, numchars);
+ if(!utf8)
+ return numchars;
+ char *decomposed = g_utf8_normalize(utf8, -1, G_NORMALIZE_NFC);
+ g_free(utf8);
+ gunichar *outbuf = convert_utf8_to_ucs4(decomposed, &outchars);
+ g_free(decomposed);
+ if(!outbuf)
+ return numchars;
+
+ /* Copy the output buffer to the original buffer */
+ memcpy(buf, outbuf, MIN(outchars, len) * 4);
+ g_free(outbuf);
+
+ return outchars;
case gestalt_Graphics:
case gestalt_GraphicsTransparency:
case gestalt_DateTime:
case gestalt_Graphics:
case gestalt_GraphicsTransparency:
case gestalt_DateTime:
+ case gestalt_UnicodeNorm:
return 1;
/* Capabilities supported if compiled with GStreamer */
return 1;
/* Capabilities supported if compiled with GStreamer */
case gestalt_LineInputEcho:
case gestalt_LineTerminatorKey:
case gestalt_LineTerminators:
case gestalt_LineInputEcho:
case gestalt_LineTerminatorKey:
case gestalt_LineTerminators:
- case gestalt_UnicodeNorm:
/* Selector not supported */
default:
return 0;
/* Selector not supported */
default:
return 0;