String::formatted fails to handle DEFINES to WideChar (when needed)


#1

On Mac it works just fine.
However on Windows the following:

#define APP_NAME	"WideCharIssue"
juce::NativeMessageBox::showOkCancelBox(juce::AlertWindow::AlertIconType::WarningIcon, APP_NAME, juce::String::formatted("Thank you for trying %s.\nAs you see JUCE has some bugs in handling defines with native dialogs.", APP_NAME), nullptr, nullptr);

Would eventually result:

The issue is within the ::formatted as debugging shows that the String itself is already encoding incorrectly (under Windows…).

My Region settings are:

  • Current System Locale: English (United States)
  • Home Location: United States.

#2

This is one of the many reasons (but probably the main reason) that I hate printf and am constantly telling you all not to use it!

The arguments get passed to the underlying library call that does the sprintf, so if you’re going to use the function, it’s up to you to deal with the implications of that - I made my opinion very clear in the documentation for it!

https://www.juce.com/doc/classString#ac42e4a0dee272e886879685dc0c83387