Activiz 9.1 display chinese

When I use vtkTextActor to display Chinese, the Chinese string is converted to utf8 and then to string, but the conversion fails for odd numbers. So, how to display odd numbers of Chinese in c#?
vtkTextActor actor = new vtkTextActor();
actor.GetTextProperty().SetFontFamily(4);
actor.GetTextProperty().SetFontFile(@“C:\Windows\Fonts\simkai.ttf”);
actor.GetTextProperty().SetFontSize(20);

        byte[] bytes = Encoding.UTF8.GetBytes("我");
        string s = Encoding.Default.GetString(bytes);
        actor.SetInput(s);

@LucasGandel

Unless there has been a recent change Activiz does not support conversion of c# strings to utf8 for proper handling of text in VTK. That means Activiz can only work with plain English text.

:sob:

You might prefer to use the Java or Python wrappers which handle the text conversion properly.

But our application is developed based on WPF. Should I use activiz for the 3D module? Or should 3D be done in c++? It seems that everyone uses the c++ version to make 3D. And there is no problem for c++ to display Chinese. I am a little troubled.

In that case I suggest you utilise C++ for the 3D module as well. Because VTK uses utf8 internally there are no problems displaying non-English text.

Well, thank you very much for your reply!

As far as Activiz goes, I raised the issue about it not supporting utf8 here Introduction to ActiViz Webinar - #8 by toddy and, two years later, nothing has been done.

It is actually not difficult to fix.

Nothing should be required on the Activiz side if you make sure your C# application is using UTF-8 characters only.
To do so, force the active codepage to UTF-8 by adding the following section in your app.manifest file:

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
    </windowsSettings>
  </application>

Using the above with the code you provided displays the chinese character just fine.

With the proviso that you can only deploy to Windows 10 machines.

By the way, who should I contact if I want to buy genuine activiz? And about invoice reimbursement. Failed to send the contact information on the official website all the time.

Sorry for not introducing myself, I’m the main maintainer of ActiViz.
I will contact you by email to provide all the information. Thanks

For information, Activiz 9.3 has been released. It uses UTF-8 encoded strings now, so setting the active codepage to UTF8 is not required anymore :tada: :partying_face:
See https://www.kitware.com/activiz-9-3-release-net-7-and-utf-8-everywhere/.

@toddy FYI

2 Likes