Difficulty Displaying Copyright Sign and Trademark Sign in Window [SOLVED]


#1

Hi there, I’m having trouble displaying a few characters using ImGui’s TextWrapped function. I’m trying to render the copyright sign (©) and the trademark sign (™) in an ImGui window, but I can’t figure out how to do so. From what I can tell, ImGui’s Text functions only take in char pointers (c strings), which use ASCII, which doesn’t have those symbols, so how do I use UTF-8 characters in the ImGui Text functions?


#2

Figured it out! Not sure why this works, but it works nonetheless, thank you Stack Overflow! https://stackoverflow.com/questions/21575310/converting-normal-stdstring-to-utf-8


#3

With C++11 (which normally any recent compiler should support) you can encode directly as UTF-8 by using the syntax u8"hello world".

This is documented in the imgui’s misc/fonts/README.txt as well as the imgui FAQ.

To display copyright and trademark you’ll also need to load a font that has those characters and specify them in the glyph ranges.