Bug with slider suffix/utf8

I have two components, that both happen to have sliders for phase.
So in my code I have this:

phaseSlider.setTextValueSuffix(juce::CharPointer_UTF8(u8"°"));

the code for these sliders is identical - literally cut and paste.

On one component, the suffix looks great.
On the other, I get this weird ‘A’ before the degree symbol.
On the slider with the weird behavior, if I change the suffix to something normal like ‘%’ - it works fine, but any character above ASCII 127 has that A in front

Can any one explain wht might be happening?

The code you shared isn’t necessarily portable, since it depends on the encoding of the source code file itself.

The most robust way to include string literals with non-ascii characters is to use C++ escape codes to represent extended characters. There’s a helper tool in the Projucer to convert UTF-8 to C++: look for “UTF-8 String Converter” in the main menu.

fair enough, but my question is not about portability.

It is why the same code in two components exhibits different behavior

Could you try using one of the techniques in this article to avoid using string literals to see if you are still experiencing the same issue. Sorry I’m away from my machine right now so I can’t try it myself.

1 Like

That resolved the issue.

Still weird about the same code doing two different things

Thanks

Eric

Were they in the same file? I wonder if one file ended up with utf8 encoding and the other didn’t?

Different files, but all in visual studio

Eric Sterling | CTO DigitalPour | 503.724.6536

www.digitalpour.com |@DigitalPour | Facebook

I think you can view and change the encoding in VS 2022 with this extension Editor Info - Visual Studio Marketplace

Or if you’re using 2026 I think this feature is standard now.

I’m not sure why they would have different encodings but that would be my guess.

1 Like