A Reference Document on RTFCONV.DLL


by HARIGAYA Soichi



Contents




Functions



RTFCONV.DLL is a thread-safe program. All functions on this documents are designed to run safely on multi-thread programs. (Some obsolete functions, which are not on this document, are not thread-safe.)


  int WINAPI RtfconvEx (
      LPCTSTR               pSrcFileName,
      LPCTSTR               pDstFileName,
      int                   nSrcCodePage,
      int                   nDstCodePage,
      const RTFCONVEXINFO * pRtfconvExInfo
  ) ;

This function performs file-type conversion between TXT and RTF, and character-code conversion between TXT files. This is the main interface of RTFCONV.DLL. If the macro "UNICODE" is defined and included "rtfconv.h", the macro "RtfconvEx" will be replaced by the Unicode version "RtfconvExW". Otherwise, the macro RtfconvEx will be replaced by the Ansi version "RtfconvExA".


/**** Parameters ****/

  LPCTSTR pSrcFileName    /* Source filename      */
  LPCTSTR pSrcFileName    /* Destination filename */
Specifies the filename of the source and the destination. A filename may be a full pathname, a relative pathname, or a UNC. If the filename is NULL, the function will open stdin or stdout.

  int nSrcCodePage        /* Source code page      */
  int nDstCodePage        /* Destination code page */
Specifies the code page of the source and the destination. You can use the codepage names defined in "rtfconv.h". If the codepage is 0, that means RTF (Rich Text Format) is specified. If the codepage is invalid in the system, the function may load some supplementary DLLs (SBCTBL.DLL, MBCTBL.DLL, CNSTBL.DLL) from the same directory with RTFCONV.DLL.

  const RTFCONVEXINFO * pRtfconvExInfo     /* Options */
Pointer to a
RTFCONVEXINFO structure that determines the options of conversion. If this parameter is NULL, the function will perform default conversion.


/**** Return Values ****/

The return value is one of the following values.

RTFCONV_SUCCESS
Conversion was successful.

RTFCONV_ERROR_UNKNOWN
Occurred unknown errors.

RTFCONV_ERROR_READ
Failed to read the source file.

RTFCONV_ERROR_WRITE
Failed to write the destination file.

RTFCONV_ERROR_RTFFORMAT
Occurred errors of RTF format.

RTFCONV_ERROR_RTFBRACE
Occurred errors of RTF format.

RTFCONV_ERROR_MEMORY
Failed to allocate required memory.

RTFCONV_ERROR_CODEPAGE
The code page is invalid.

RTFCONV_ERROR_ABORTED
Aborted by AbortRtfconv during conversion.

RTFCONV_ERROR_PARAM
Specified parameters are invalid.

You can also get these return values by GetRtfconvLastError.






  intptr_t WINAPI RtfconvStringEx (
      const void *          pSrcBuffer,
      void *                pDstBuffer,
      int                   nSrcCodePage,
      int                   nDstCodePage,
      const RTFCONVEXINFO * pRtfconvExInfo,
      size_t                nMaxLen
  ) ;

This function performs string-type and character-code conversion of strings.


/**** Parameters ****/

  const void * pSrcBuffer       /* Pointer to the source string */
  void * pDstBuffer             /* Pointer to the destination buffer */
Specifies the pointer to the source string and the destination buffer. Both are declared as a void pointer, so you can specify char or wchar_t string buffers without cast. The string pointed to by pSrcBuffer must be null-terminated. If the same address is specified to pSrcBuffer and pDstBuffer, the result of conversion is undefined.

If pDstBuffer is NULL, the function will not perform conversion, and returns the required size of destination buffer in bytes. In this case, nMaxLen will be ignored.

  int nSrcCodePage              /* Source codepage */
  int nDstCodePage              /* Destination codepage */
Specifies the code page of the source and the destination. You can use the codepage names defined in "rtfconv.h". If the codepage is 0, that means RTF (Rich Text Format) is specified. If the codepage is invalid in the system, the function may load some supplementary DLLs (SBCTBL.DLL, MBCTBL.DLL, CNSTBL.DLL) from the same directory with RTFCONV.DLL.

  const RTFCONVEXINFO * pRtfconvExInfo     /* Options */
Pointer to a
RTFCONVEXINFO structure that determines the options of conversion. If this parameter is NULL, the function will perform default conversion.

  size_t nMaxLen            /* Size of destination buffer */
Specifies the size of destination buffer, in bytes.


/**** Return Value ****/

The return value is the number of bytes written to the buffer pointed to by pDstBuffer.
If it failed to convert, it will return -1. To get more information, call GetRtfconvLastError.

If pDstBuffer is NULL, it will return the required size of destination buffer in bytes.






  int WINAPI RtfconvCharEx (
      int                   C,
      int                   nSrcCodePage,
      int                   nDstCodePage,
      const RTFCONVEXINFO * pRtfconvExInfo
  ) ;

This function converts a character to other codepages.


/**** Parameters ****/
  int C                         /* Character */
Specifies a character code.
  int nSrcCodePage              /* Source codepage */
  int nDstCodePage              /* Destination codepage */
Specifies the code page of the source and the destination. You can use the codepage names defined in "rtfconv.h". If the codepage is 0, that means RTF (Rich Text Format) is specified. If the codepage is invalid in the system, the function may load some supplementary DLLs (SBCTBL.DLL, MBCTBL.DLL, CNSTBL.DLL) from the same directory with RTFCONV.DLL.
You cannot set a "modal" codepages to these parameters, like ISO-2022-JP or HZ etc.
  const RTFCONVEXINFO * pRtfconvExInfo     /* Options */
Pointer to a
RTFCONVEXINFO structure that determines the options of conversion. If this parameter is NULL, the function will perform default conversion.


/**** Return Value ****/

The return value is a character.
If it failed to convert, it will return -1. To get more information, call GetRtfconvLastError.






  int WINAPI IsRtfconvValidCodePage (
      int nCodePage
  ) ;

Test whether RTFCONV.DLL supports a specified code page.


/**** Return Value ****/

If the specified codepage is supported, return 1.
If the specified codepage is not supported, return 0.







  int WINAPI GetRtfconvLastError (
      void
  ) ;

Get the calling thread's last-error code of
RtfconvEx, RtfconvStringEx, or RtfconvCharEx.


/**** Return Value ****/

The return value is one of the following values.

RTFCONV_SUCCESS
Conversion was successful.

RTFCONV_ERROR_UNKNOWN
Occurred unknown errors.

RTFCONV_ERROR_READ
Failed to read the source file.

RTFCONV_ERROR_WRITE
Failed to write the destination file.

RTFCONV_ERROR_RTFFORMAT
Occurred errors of RTF format.

RTFCONV_ERROR_RTFBRACE
Occurred errors of RTF format.

RTFCONV_ERROR_MEMORY
Failed to allocate required memory.

RTFCONV_ERROR_CODEPAGE
The code page is invalid.

RTFCONV_ERROR_ABORTED
Aborted by AbortRtfconv during conversion.

RTFCONV_ERROR_PARAM
Specified parameters are invalid.







  int WINAPI AbortRtfconv (
      void
  ) ;

If you call this function while
RtfconvEx or RtfconvStringEx is running in the process, these functions may stop conversion and return an error-code. AbortRtfconv will affect all threads of the process.


/**** Return Value ****/

The return value is always 0.






  int WINAPI GetDllVersion (
      void
  ) ;

Get the version of RTFCONV.DLL.


/**** Return Value ****/

If the version of RTFCONV.DLL is 5.31, the function returns 531.





Structures



  typedef struct {
        size_t                cbSize ;
        unsigned long         dwConversionMode ;
        unsigned long         dwAdditionalMode ;
        const char *          pUnmappableCharFormat ;
        int                   nDefaultCjkCodePage ;
        int                   nFontSize ;
        const RTFFONTINFO *   pFontInfo ;
        const RTFFONTEXINFO * pFontExInfo ;
        size_t                nNumberOfFontExInfo ;
        const RTFLANGIDINFO * pLangIdInfo ;
        size_t                nNumberOfLangIdInfo ;
        const void *          pReserved ;
  } RTFCONVEXINFO ;

/**** Members ****/

cbSize
Specifies the length, in bytes, of the structure.

dwConversionMode
Specifies a combination of the following flag constants. If this member is 0, the function will perform conversion with default options.

CONVMODE_PEEKMESSAGE
Peek messages during conversion.

CONVMODE_OUTPUT_CODE_NUMBER
Write its Unicode Number like "[UNICODE:hhh]" for unmappable characters. You can change the format by pUnmappableCharFormat.

CONVMODE_OUTPUT_CODE_NUMBER_HTML
Write its Unicode Number like "&#xhhh" for unmappable characters.

CONVMODE_OUTPUT_NUMBER_SURROGATE
Write its Unicode Number by UTF-16 surrogate pair when specified CONVMODE_OUTPUT_CODE_NUMBER or CONVMODE_OUTPUT_CODE_NUMBER_HTML.

CONVMODE_INPUT_CODE_NUMBER_HTML
Recognize &#nnn; or &#xhhh; as Unicode Character.

CONVMODE_NO_VARIANT_KANJI
Do not convert to character variants. This flag is valid for characters above U+2E80.

CONVMODE_NO_VARIANT_EUROPEAN
Do not convert to character variants. This flag is valid for characters under U+2E7F.

CONVMODE_NO_VARIANT
Do not convert to character variants. This flag is equivalent to the combination of CONVMODE_NO_VARIANT_KANJI and CONVMODE_NO_VARIANT_EUROPEAN.

CONVMODE_VARIANT_ONLY_ROUNDTRIP
Convert to character variants only when the conversion is "roundtrippable".

CONVMODE_CONVERT_PUA
Enable to convert Private Use Area.

CONVMODE_NO_HANKANA
Convert single-byte kana to double-byte.

CONVMODE_NO_ZENALPHA
Convert double-byte alphabets and digits to single-byte.

CONVMODE_NO_ZENSPACE
Convert double-byte space to single-byte.

CONVMODE_NO_ZENSYMBOL
Convert double-byte symbols to single-byte.

CONVMODE_YEN_NO_BACKSLASH
Convert Japanese/Korean single-byte Yen/Won Sign to U+A5/U+20A9, not to backslash.

CONVMODE_USE_LOCAL_FONT
Write the same font for double-byte characters and single-byte characters on writing RTF.

CONVMODE_NO_GBK
Write GB2312 only (on writing Chinese Simplified).

CONVMODE_OUTPUT_GB18030
Write GB2312 + GBK + GB18030 (on writing Chinese Simplified).

CONVMODE_NO_CW
Do not recognize the fonts of Chinese Writer, Korean Writer and SIL in RTF.

CONVMODE_OUTPUT_RUBY
Write Ruby (Pronunciation Guide) of RTF.

CONVMODE_OUTPUT_LINK
Write Hyperlinks of RTF.

CONVMODE_OUTPUT_HIDDEN
Write Hidden Characters of RTF.

CONVMODE_OUTPUT_CR
Write CR only.

CONVMODE_OUTPUT_LF
Write LF only.

CONVMODE_USE_DLL_TABLE
Always use SBCTBL.DLL, MBCTBL.DLL.

CONVMODE_USE_SYSTEM_TABLE
Never use SBCTBL.DLL, MBCTBL.DLL.

CONVMODE_NO_OUTPUT_BOM
Do not write a Byte Order Marks (on writing UTF-16/32).

CONVMODE_UTF8_WITH_BOM
Write a Byte Order Mark (on writing UTF-8).

CONVMODE_ENDIAN_AUTO
Detect the Endian automatically (on reading UTF16/32).

CONVMODE_EUC_HOJO
Write JIS X 0212 (Hojo Kanji) of EUC-JP

dwAdditionalMode
Specifies some additional options. The following constants will be specified to this member. If this member is 0, the function will performs conversion with default options.

ADDITIONAL_MODE_JIS_INPUT_MAC
Read Japanese text by Macintosh Japanese Character Set.

ADDITIONAL_MODE_JIS_OUTPUT_MAC
Write Japanese text by Macintosh Japanese Character Set.

ADDITIONAL_MODE_JIS_OUTPUT_NO_VENDOR
Do not write Japanese Vendor Characters. Write Japanese text by JIS X 0208:1997.

ADDITIONAL_MODE_JIS_INPUT_NO_VENDOR
Do not read Japanese Vendor Characters. Read Japanese text by JIS X 0208:1997.

ADDITIONAL_MODE_JIS_INPUT_2004
Read Japanese text by JIS X 0213:2004.

ADDITIONAL_MODE_JIS_OUTPUT_2004
Write Japanese text by JIS X 0213:2004.

ADDITIONAL_MODE_JIS_NO_JIS83_NEW_STYLE
Do not write JIS83 new style characters.

ADDITIONAL_MODE_JIS_NO_JIS83_OLD_STYLE
Do not write JIS83 old style characters.

ADDITIONAL_MODE_GBK_TO_LINSHIDAIMA
Convert GBK to Unicode PUA (GB13000 Linshi Daima).

ADDITIONAL_MODE_LINSHIDAIMA_TO_GBK
Convert Unicode PUA (GB13000 Linshi Daima) to GBK.

ADDITIONAL_MODE_PUA_TO_HKSCS
Convert PUA to HKSCS (on writing HKSCS).

ADDITIONAL_MODE_HKSCS_CJKA_TO_PUA
Convert CJK Ex.A to PUA (on reading HKSCS).

ADDITIONAL_MODE_HKSCS_CJKB_TO_PUA
Convert CJK Ex.B to PUA (on reading HKSCS).

ADDITIONAL_MODE_HKSCS_CJK41_TO_PUA
Convert Unicode 4.1 or later to PUA (on reading HKSCS).

ADDITIONAL_MODE_HKSCS_ALL_TO_PUA
Convert all characters to PUA if can (on reading HKSCS).

ADDITIONAL_MODE_HKSCS_1999
Convert to HKSCS-1999 (on writing HKSCS).

ADDITIONAL_MODE_HKSCS_2001
Convert to HKSCS-2001 (on writing HKSCS).

ADDITIONAL_MODE_KS_NO_UHC
Do not write Korean UHC extended characters (on writing Korean).

ADDITIONAL_MODE_KS_PUNC
Convert U+3001 and U+3002 to "comma" and "full stop" (on writing Korean).

pUnmappableCharFormat
Specifies the string format for writing unmappable characters. This member will be valid only when the flag CONVMODE_OUTPUT_CODE_NUMBER is specified to dwConversionMode. The syntax of this string follows the format of printf(). If this member is NULL, the function will use the default format.

nDefaultCjkCodePage
Specifies the codepage of CJK characters for the conversion of Unicode to RTF. This member must be Japanese (932), Chinese Simplified (936), Chinese Traditional (950), Korean (949), or 0 (default).

nFontSize
Specifies the font size for writing RTF. This member is 0, the function will write the default font size.

pFontInfo
Specifies the pointer to the
RTFFONTINFO structure. If this member is NULL, the function will use the default font face names.

pFontExInfo
Specifies the pointer to the array of
RTFFONTEXINFO structure. If this member is NULL, the function will use the default font face names.

nNumberOfFontExInfo
Specifies the length of array of
RTFFONTEXINFO structure, which is specified to pFontExInfo member. If the pFontExInfo member is NULL, set this member to 0.

pLangIdInfo
Specifies the pointer to the array of
RTFLANGIDINFO structure. If this member is NULL, the function will use the default LANGID numbers.

nNumberOfLangIdInfo
Specifies the length of array of
RTFLANGIDINFO structure, which is specified to pLangIdInfo member. If the pLangIdInfo member is NULL, set this member to 0.

pReserved
Reserved. Set this member to NULL.






  typedef struct {
        size_t        cbSize ;
        const char *  pEuropean ;
        const char *  pJapanese ;
        const char *  pChineseSimplified ;
        const char *  pChineseTraditional ;
        const char *  pKorean ;
        const char *  pThai ;
  } RTFFONTINFO ;

/**** Members ****/

cbSize
Specifies the length, in bytes, of the structure.

pEuropean
Specifies the font face name for European characters, which will be used on writing RTF. If this member is NULL, the function will use the default font face name.

pJapanese
Specifies the font face name for Japanese characters, which will be used on writing RTF. If this member is NULL, the function will use the default font face name.

pChineseSimplified
Specifies the font face name for Chinese Simplified characters, which will be used on writing RTF. If this member is NULL, the function will use the default font face name.

pChineseTraditional
Specifies the font face name for Chinese Traditional characters, which will be used on writing RTF. If this member is NULL, the function will use the default font face name.

pKorean
Specifies the font face name for Korean characters, which will be used on writing RTF. If this member is NULL, the function will use the default font face name.

pThai
Specifies the font face name for Thai characters, which will be used on writing RTF. If this member is NULL, the function will use the default font face name.






  typedef struct {
        int          C ;
        const char * pFont ;
  } RTFFONTEXINFO ;

/**** Members ****/

C
Specifies a character block of Unicode. Usually, specify the first character of a block. For more information about Unicode block, read
http://www.unicode.org/Public/UNIDATA/Blocks.txt. If this member is -1, set a value to all the blocks.

pFont
Specifies a font face name. The function will write characters of the block specified by the member C with this font on writing RTF. If this member is NULL, the function will write a default font face name.






  typedef struct {
        int  C ;
        int  nLangId ;
  } RTFLANGIDINFO ;

/**** Members ****/

C
Specifies a character block of Unicode. Usually, specify the first character of a block. For more information about Unicode block, read
http://www.unicode.org/Public/UNIDATA/Blocks.txt. If this member is -1, set a value to all the blocks.

nLangId
Specifies a LANGID. The function will write characters of the block specified by the member C with this LANGID on writing RTF. If this member is NULL, the function will write a default LANGID.





Sample



/**** Sample 1 ****/

/* Convert a Japanese Text File to Unicode */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.txt"), CP_JAPANESE, CP_UTF16, NULL ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 2 ****/

/* Convert a Japanese Text File to RTF. */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.rtf"), CP_JAPANESE, 0, NULL ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 3 ****/

/* Convert a Japanese Text File to ISO-2022-JP, and convert half-width katakanas */
/* to their full-width equivalents.                                              */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Structures */
    RTFCONVEXINFO RtfconvExInfo = { sizeof(RTFCONVEXINFO) } ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Options */
    RtfconvExInfo.dwConversionMode = CONVMODE_NO_HANKANA ;

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.txt"), CP_JAPANESE, CP_ISO_JAPANESE, & RtfconvExInfo ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 4 ****/

/* Convert a Unicode String "hello, world!" to Western European codepage, and */
/* display it by MessageBox                                                   */

#include <windows.h>
#include "rtfconv.h"

typedef intptr_t (WINAPI *RTFCONVSTRINGEX) ( const void *pSrcBuffer, void *pDstBuffer,
      int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo,
      size_t nMaxLen ) ;


int main () {

    char szBuffer [ 0x100 ] ;

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVSTRINGEX pRtfconvStringEx ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

    pRtfconvStringEx = (RTFCONVSTRINGEX) GetProcAddress( hRtfconv, "RtfconvStringEx" ) ;
    if ( pRtfconvStringEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Conversion */
    pRtfconvStringEx( L"hello, world!", szBuffer, CP_UTF16, 1252, NULL, sizeof(szBuffer) );

    /* Display */
    MessageBoxA( NULL, szBuffer, "test", MB_OK ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 5 ****/

/* Convert a Japanese Text File to RTF, with "Arial" to Ascii characters, */
/* "MS PGothic" to Japanese characters.                                   */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Structures */
    RTFCONVEXINFO RtfconvExInfo = { sizeof(RTFCONVEXINFO) } ;
    RTFFONTINFO FontInfo = { sizeof(RTFFONTINFO) } ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Options */
    FontInfo.pEuropean = "Arial" ;
    FontInfo.pJapanese = "MS PGothic" ;
    RtfconvExInfo.pFontInfo = & FontInfo ;

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.rtf"), CP_JAPANESE, 0, & RtfconvExInfo ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 6 ****/

/* Convert a Japanese Text File to RTF, with "MS PGothic" to all */
/* characters.                                                   */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Structures */
    RTFCONVEXINFO RtfconvExInfo = { sizeof(RTFCONVEXINFO) } ;
    RTFFONTINFO FontInfo = { sizeof(RTFFONTINFO) } ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Options */
    FontInfo.pJapanese = "MS PGothic" ;
    RtfconvExInfo.pFontInfo = & FontInfo ;
    RtfconvExInfo.dwConversionMode = CONVMODE_USE_LOCAL_FONT ;

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.rtf"), CP_JAPANESE, 0, & RtfconvExInfo ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 7 ****/

/* Convert a KOI8-U text file to RTF.             */
/* Write Ukrainian LangId to Cyrillic characters. */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Structures */
    RTFCONVEXINFO RtfconvExInfo = { sizeof(RTFCONVEXINFO) } ;

    RTFLANGIDINFO LangIdInfo [] = {
    	{ 0x0400, MAKELANGID( LANG_UKRAINIAN, SUBLANG_DEFAULT ) },    /* Cyrillic (0x0400`0x04FF) */
    } ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Options */
    RtfconvExInfo.pLangIdInfo = LangIdInfo ;
    RtfconvExInfo.nNumberOfLangIdInfo = sizeof(LangIdInfo) / sizeof(LangIdInfo[0]) ;

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.rtf"), CP_CYRILLIC_KOI8U, 0, & RtfconvExInfo ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 8 ****/

/* Convert Unicode Text File to RTF.      */
/* Write Yi characters with font "SIL Yi" */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Structures */
    RTFCONVEXINFO RtfconvExInfo = { sizeof(RTFCONVEXINFO) } ;

    RTFFONTEXINFO FontExInfo [] = {
        { 0xA000, "SIL Yi" },      /* Yi Syllables (0xA000`0xA48F) */
        { 0xA490, "SIL Yi" },      /* Yi Radicals  (0xA490`0xA4CF) */
    } ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Options */
    RtfconvExInfo.pFontExInfo = FontExInfo ;
    RtfconvExInfo.nNumberOfFontExInfo = sizeof(FontExInfo) / sizeof(FontExInfo[0]) ;

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.rtf"), CP_UTF16, 0, & RtfconvExInfo ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 9 ****/

/* Convert a Japanese Text File to Unicode. */
/* Write '?' for unmappable characters.     */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Structures */
    RTFCONVEXINFO RtfconvExInfo = { sizeof(RTFCONVEXINFO) } ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Options */
    RtfconvExInfo.pUnmappableCharFormat = "?" ;
    RtfconvExInfo.dwConversionMode = CONVMODE_OUTPUT_CODE_NUMBER ;

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.txt"), CP_UTF16, CP_JAPANESE, & RtfconvExInfo ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}




/**** Sample 10 ****/

/* Convert a Chinese Simplified Text File to Japanese.             */
/* Write [UC+HHHH] (hexadecimal digits) for unmappable characters. */

#include <windows.h>
#include "rtfconv.h"

typedef int (WINAPI *RTFCONVEX) ( LPCTSTR pSrcFileName, LPCTSTR pDstFileName,
     int nSrcCodePage, int nDstCodePage, const RTFCONVEXINFO *pRtfconvExInfo ) ;


int main () {

    /* DLL */
    HINSTANCE hRtfconv ;
    RTFCONVEX pRtfconvEx ;

    /* Structures */
    RTFCONVEXINFO RtfconvExInfo = { sizeof(RTFCONVEXINFO) } ;

    /* Reading DLL */
    hRtfconv = LoadLibrary( TEXT("rtfconv.dll") ) ;
    if ( hRtfconv == NULL ) {
        return 1 ;
    }

#ifdef UNICODE
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExW" ) ;
#else
    pRtfconvEx = (RTFCONVEX) GetProcAddress( hRtfconv, "RtfconvExA" ) ;
#endif
    if ( pRtfconvEx == NULL ) {
        FreeLibrary( hRtfconv ) ;
        return 1 ;
    }

    /* Options */
    RtfconvExInfo.pUnmappableCharFormat = "[UC+%04X]" ;
    RtfconvExInfo.dwConversionMode = CONVMODE_OUTPUT_CODE_NUMBER ;

    /* Conversion */
    pRtfconvEx ( TEXT("c:\\foo.txt"), TEXT("c:\\poo.txt"), CP_CHINESE_SIMPLIFIED, CP_JAPANESE, & RtfconvExInfo ) ;

    /* Finalization */
    FreeLibrary( hRtfconv ) ;
    return 0 ;
}