richedit: Fixed the call to the EditWordBreakProc.
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 97b5a67..7da521c 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -304,6 +304,8 @@
   /* FIXME: Native also knows about punctuation */
   TRACE("s==%s, start==%d, len==%d, code==%d\n",
         debugstr_wn(s, len), start, len, code);
+  /* convert number of bytes to number of characters. */
+  len /= sizeof(WCHAR);
   switch (code)
   {
     case WB_ISDELIMITER:
@@ -330,11 +332,23 @@
 int
 ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code)
 {
-  /* FIXME: ANSIfy the string when bEmulateVersion10 is TRUE */
-  if (!editor->pfnWordBreak)
-    return ME_WordBreakProc(str->szData, start, str->nLen, code);
-  else
-    return editor->pfnWordBreak(str->szData, start, str->nLen, code);
+  if (!editor->pfnWordBreak) {
+    return ME_WordBreakProc(str->szData, start, str->nLen*sizeof(WCHAR), code);
+  } else if (!editor->bEmulateVersion10) {
+    /* MSDN lied about the third parameter for EditWordBreakProc being the number
+     * of characters, it is actually the number of bytes of the string. */
+    return editor->pfnWordBreak(str->szData, start, str->nLen*sizeof(WCHAR), code);
+  } else {
+    int result;
+    int buffer_size = WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
+                                          NULL, 0, NULL, NULL);
+    char *buffer = (char*)heap_alloc(buffer_size);
+    WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
+                        buffer, buffer_size, NULL, NULL);
+    result = editor->pfnWordBreak(str->szData, start, str->nLen, code);
+    heap_free(buffer);
+    return result;
+  }
 }
 
 LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz)