ofToUpper with latin characters (utf8 encoding)

#1

I’m having difficulties converting some text to uppercase, like INFORMAçãO instead of INFORMAÇÃO
I’ve seen ofToUpper has an optional parameter called locale, but I’m not sure how to use it.
I’m printing to console, so it is not a font loading issue.
Any tips of how to do the right way?
Thank you

#2

I think it wants std:locale names (MS page about them), as listed on this page.

The accepted answer HERE suggests using a locale of “en_US.iso885915” for this purpose.

1 Like
#3

if you don’t specify a locale it’ll take the default one from the system. if the OS language is in portuguese that should be capitalized correctly but if it’s in english then it won’t understand the ç and ã.

to be sure you can set it manually by alling

ofToUpper(text, "pt_BR.UTF-8");

This should work on linux and mac but windows might have some differences in how you set the locale code. if that doesn’t work try;

ofToUpper(text, "pt_BR");

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=vs-2019

2 Likes
#4

Thank you @arturo, it works great.

1 Like