ImGui.NET icon indicating copy to clipboard operation
ImGui.NET copied to clipboard

"How to display UTF-8 encoded text using ImGui.NET in C#"

Open HuaChenDu opened this issue 1 year ago • 6 comments

Resolving the issue of UTF-8 strings displaying as '??????' 屏幕截图 2024-04-23 085923 屏幕截图 2024-04-23 085800 屏幕截图 2024-04-23 085945

HuaChenDu avatar Apr 23 '24 01:04 HuaChenDu

屏幕截图 2024-04-23 090336 屏幕截图 2024-04-23 090400 I attempt to solve using the mindset of C++ code, or to display???

HuaChenDu avatar Apr 23 '24 01:04 HuaChenDu

You need to do something like what is described here: https://github.com/ImGuiNET/ImGui.NET/issues/67

mellinoe avatar Apr 23 '24 01:04 mellinoe

You need to do something like what is described here: #67 I still don't understand. Could you teach me how to modify my code? my code: namespace ImGuiNET { public class Program : Overlay { bool checkBoxValue = false; int loveMeter = 0; string input = ""; string input2 = ""; bool showWindow = true;

	protected override void Render()
	{
		ImGui.Begin("XuanYuFuZhu",  ref checkBoxValue);

		string chineseText = "这里显示中文";
		ImGui.Text(chineseText);


		if (!showWindow)
		{
			System.Environment.Exit(0);
		}
	}


	public void CloseWindowAndExit()
	{
		showWindow = false;
	}

	public static void Main(string[] args)
	{
		Program program = new Program();
		program.Start().Wait();
	}
}

}

HuaChenDu avatar Apr 23 '24 15:04 HuaChenDu

You need to do something like what is described here: #67

Uploading 屏幕截图 2024-04-24 164844.png… Thank you very much for your help. After 2 days of trial and error, I added this line 'ImGui.CreateContext();' on top of the method you provided, and now it can display Chinese characters.

HuaChenDu avatar Apr 24 '24 08:04 HuaChenDu

Can you provide the code? Thanks!

abo-nb avatar May 04 '24 14:05 abo-nb