Fix ccallFunc to properly support UTF-8 strings

As pointed out in #1166, ccallFunc fails to calculate the required amount of memory for a string, if it contains non-ascii characters. I fixed it by converting the string into an array, then writing that array into memory. That's basically the same writeStringToMemory() does but I can use the array length to determine the necessary memory.