From 18479d5e7eccb94c7fd15af3cfca034db081a688 Mon Sep 17 00:00:00 2001 From: Emily Noneman Date: Thu, 25 Aug 2022 17:38:03 -0400 Subject: [PATCH] Use string_chars instead of string_to_utf8 in UNICODE mode --- src/bootstrap.c | 5 +++++ src/runtimes/mono.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/bootstrap.c b/src/bootstrap.c index 6cc60e4..cff4add 100644 --- a/src/bootstrap.c +++ b/src/bootstrap.c @@ -114,8 +114,13 @@ void mono_doorstop_bootstrap(void *mono_domain) { LOG("Error invoking code!"); if (mono.object_to_string) { void *str = mono.object_to_string(exc, NULL); +#ifdef UNICODE + char_t *exc_str = mono.string_chars(str); + LOG("Error message: %s", exc_str); +#else char *exc_str = mono.string_to_utf8(str); LOG("Error message: %s", exc_str); +#endif } } LOG("Done"); diff --git a/src/runtimes/mono.h b/src/runtimes/mono.h index 2a55f7d..9a2d081 100644 --- a/src/runtimes/mono.h +++ b/src/runtimes/mono.h @@ -27,6 +27,9 @@ DEF_CALL(void, config_parse, const char *filename) DEF_CALL(void, set_assemblies_path, const char *path) DEF_CALL(void *, object_to_string, void *obj, void **exc) DEF_CALL(char *, string_to_utf8, void *s) +#ifdef UNICODE +DEF_CALL(char_t *, string_chars, void *mono_string) +#endif DEF_CALL(void *, image_open_from_data_with_name, void *data, unsigned long data_len, int need_copy, MonoImageOpenStatus *status, int refonly, const char *name)