c# - mono and passing on unicode strings -
c# - mono and passing on unicode strings -
i'm embedding mono in application of mine have issues mono's string conversion.
c++ code:
static inline void p_print(monostring *str) { cout << "utf8: " << mono_string_to_utf8(str) << endl; wcout << "utf16: " << ((wchar_t*)mono_string_to_utf16(str)) << endl; } //... mono_add_internal_call("sampsharp.gamemode.natives.native::print", (void *)p_print);
c# code:
[methodimpl(methodimploptions.internalcall)] public static extern void print(string msg); //... print("characters \u00d6 working? (should o \" above it)");
output:
utf8: characters ├û working? (should o " above it) utf16: characters Í working? (should o " above it)
as can see, output not quite should print, should printing "characters Ö working? (should o " above it)", neither mono_string_to_utf8 or _to_utf16 should do.
how can solve issue?
solved follows:
string mono_string_to_string(monostring *str) { mono_unichar2 *chl = mono_string_chars(str); string out(""); (int = 0; < mono_string_length(str); i++) { out += chl[i]; } homecoming out; }
might not beautiful way of doing it, works.
c# c++ unicode mono
Comments
Post a Comment