Skip to content

Conversation

@xelrach
Copy link

@xelrach xelrach commented Aug 26, 2022

The original code was taking a MonoString and then calling string_to_utf8 on it. That result was passed to LOG, which called narrow on the result, which was mangling our string.

Before:
Error invoking code!
Error message: 祓瑳浥吮灹䱥慯䕤捸灥楴湯›潃汵⁤潮⁴潬摡琠灹⁥景映敩摬✠協獅楰湯条⹥獅楰湯条䍥湯楦㩧楨敤汐祡牥 ...

After:
Error invoking code!
Error message: System.TypeLoadException: Could not load type of field 'TSEspionage.EspionageConfig:hidePlayers' (1) due to: Could not load file or assembly 'System.Collections, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:System.Collections, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type: member:(null) signature:
at Doorstop.Entrypoint.Start () [0x00001] in ...

@ghorsington
Copy link
Member

Greetings!

Thank you for your PR and sorry for the wait! I see this being an issue on Windows where strings might be internally Unicode depending on mono version. However, I am unsure how well that applies to all mono versions on different OSs.

How about instead of using mono_string_chars and having a separate preprocessor check one would simply do

char *exc_str_n = mono.string_to_utf8(str);
char_t *exc_str = widen(exc_str_n);
LOG("Error message: %s", exc_str);

widen is a helper function in Doorstop to convert char/wchar_t to the general char_t which LOG supports:

https://github.com/NeighTools/UnityDoorstop/blob/master/src/util/util.h#L36-L44

widen already has necessary preprocessor checks for different OSs (it's either a conversion or no-op depending on OS).

@ManlyMarco
Copy link
Collaborator

This issue was resolved by merging #58

@ManlyMarco ManlyMarco closed this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants