Changed method for converting between java and c strings, to convert using an intermediate wchar_t string. Should be more reliable than trying to probe the character encoding.