Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In Hoops Publish API, every character string must be given as A3DUTF8Char*. However, when dealing with foreign characters such as Japanese or Russian ones, they are initially given as Unicode strings.

This article is showing how to convert Unicode strings to UTF8Char strings, to display foreign characters in a PDF file.

Here is an example with a Japanese character string:

  1. Allocate the destination string

  2. Convert the Unicode string to the UTF8 one

    wchar_t sString[] = L"新細明體";
    A3DUTF8Char* pcDestString = new A3DUTF8Char[500];
    A3DMiscUnicodeToUTF8((const A3DUTF8Char*)sString, pcDestString );

Now pcDestString can be used in any function or field data requiring a UTF8 string. And the Japanese characters will be displayed correctly in the PDF file.

In Visual Studio, if a source file contains directly foreign characters, then the source file must be saved with a correct encoding, such as: Unicode (UTF-8 with signature) - Codepage 65001.

  • No labels