Assert with degree symbol as slider suffix

Hi there,

I am getting reports that setting a unicode degree symbol as suffix to a slider triggers an assert:

slider.setTextValueSuffix (juce::String::fromUTF8 ("\u00B0"));

What would be the correct way to write that? Or is that a bug?

That code was used successfully for a while by many people using foleys PluginGuiMagic. And it is only a problem on windows:

Thanks,
Daniel

You can either add the “u8” unicode string literal to the front of your string, so in this case I think you would want…

slider.setTextValueSuffix (juce::String::fromUTF8 (u8"\u00B0"));

or provide the UTF-8 hexadecimal values (rather than code points at used above), using numeric escape sequence. However, in this case do NOT use the “u8” unicode string literal!!

slider.setTextValueSuffix (juce::String::fromUTF8 ("\xc2\xb0"));

To get the hexadecimal string required the “UTF-8 String Literal Helper” under the Tools menu in the Projucer is useful.

More information here if you need it Technical Deep Dive: Unicode Literals - JUCE

2 Likes

Thank you @anthony-nicholls !

That solves the issue. Seems I was a bit careless when I wrote that bit.
I am aware of the tool in Projucer, I think I just copied the unicode from some internet chart without thinking.

Your link helps a lot to get a better understanding for unicodes in source files, many thanks for that.

1 Like

TIL about juce::String::fromUTF8()! I always use juce::CharPointer_UTF8{} copied from the Projucer tool - @anthony-nicholls could that tool be updated to use fromUTF8()?