📄 chnconv.h
字号:
// chnconv.h
#ifndef CHNCONV_H
#define CHNCONV_H
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////
// 僀儞僞乕僼僃僀僗 //
////////////////////////////////////////////
typedef struct {
size_t cbSize ;
const char *pGbFont ;
const char *pGbGothicFont ;
const char *pBig5Font ;
const char *pBig5GothicFont ;
const char *pPinyinFont ;
const char *pPinyinGothicFont ;
} CHNFONTINFO ;
typedef struct {
int nSrc ;
int nDst ;
} CHNCONV_USERDEF ;
typedef struct {
size_t cbSize ;
unsigned long dwConversionMode ;
unsigned long dwAdditionalMode ;
// Writing RTF
const CHNFONTINFO *pFontInfo ;
// User-Defined Conversion
const CHNCONV_USERDEF *pSrcToDst ;
size_t nNumberOfSrcToDst ;
const CHNCONV_USERDEF *pSrcToUc ;
size_t nNumberOfSrcToUc ;
// Reading TechnoMate
int nFontSize ;
// Reserved
void *pReserved ;
} CHNCONVEXINFO ;
// 曄姺儌乕僪
#define CONVMODE_OUTPUT_CODE_NUMBER 1
#define CONVMODE_CHNCONV_NO_GBK 2
#define CONVMODE_CHNCONV_NO_VARIANT 4
#define CONVMODE_SENSE_CW_FANTIZI 8
#define CONVMODE_QUOTATION_MARK 0x10
#define CONVMODE_INPUT_CODE_NUMBER 0x20
#define CONVMODE_PINYIN_BY_ASCII 0x40
#define CONVMODE_OUTPUT_NEW_FONT 0x80
#define CONVMODE_ONE_QUESTION_MARK 0x100
#define CONVMODE_CW_TXT_FANTIZI 0x800
#define CONVMODE_TM_NO_OUTPUT_RTFFORM 0x1000 // obsolete
#define CONVMODE_NO_MULTI_CHAR 0x2000
#define CONVMODE_TXT_UNICODE_HTML 0x4000
#define CONVMODE_NO_USE_UNICODE 0x8000
#define CONVMODE_CONVERT_CJKEX 0x10000
#define CONVMODE_LINGSHIDAIMA_TO_CJKEX 0x20000
#define CONVMODE_CJKEX_TO_LINGSHIDAIMA 0x40000
#define CONVMODE_CONVERT_TXT 0x1000000
#define CONVMODE_CONVERT_RTF 0x2000000
#define CONVMODE_PEEKMESSAGE 0x80000000
#if defined CHNCONV_DLL
#define CONVMODE_FILENAME_UNICODE 0x40000000
#endif
// 奼挘曄姺儌乕僪
#define ADDITIONAL_MODE_WRITE_TM_COMMENT 1
// for TechnoMate拞崙岅 obsolete
#define TMMODE_ASCII_ALL 1
#define TMMODE_ASCII_ALPHA 2
#define TMMODE_ASCII_ITALIC 4
#define TMMODE_ASCII_BOLD 8
#define TMMODE_ASCII_SMALL 0x10
#define TMMODE_ZENTOHAN 0x20
#define TMMODE_WRITE_COMMENT 0x40
// 僐乕僪儁乕僕
#define CP_JAPANESE_CW ( CP_JAPANESE + 0x10000 )
#define CP_JAPANESE_NH ( CP_JAPANESE + 0x20000 )
#define CP_JAPANESE_CWN ( CP_JAPANESE + 0x30000 )
#define CP_JAPANESE_ZQ ( CP_JAPANESE + 0x40000 )
#define CP_JAPANESE_CX ( CP_JAPANESE + 0x50000 )
#define CP_JAPANESE_TM ( CP_JAPANESE + 0x60000 )
#define CP_JAPANESE_ZJ ( CP_JAPANESE + 0x70000 )
#define CP_JAPANESE_FW ( CP_JAPANESE + 0x80000 )
#ifndef RESERVEDMODE_NO_START
typedef struct {
size_t cbSize ;
unsigned long dwMode ;
} RESERVEDINFO ;
// pReserved->dwMode, dwReserved
#define RESERVEDMODE_NO_START 1
#define RESERVEDMODE_NO_END 2
#define RESERVEDMODE_ONLY_START 4
#define RESERVEDMODE_ONLY_END 8
#define RESERVEDMODE_NO_START_END ( RESERVEDMODE_NO_START | RESERVEDMODE_NO_END )
#endif
#ifdef CHNCONV_DLL
// 怴偟偄娭悢
int WINAPI ChnconvExA ( const char *szSrcFileName, const char *szDstFileName, int nSrcCodePage, int nDstCodePage, const CHNCONVEXINFO *pInfo ) ;
int WINAPI ChnconvExW ( const wchar_t *szSrcFileName, const wchar_t *szDstFileName, int nSrcCodePage, int nDstCodePage, const CHNCONVEXINFO *pInfo ) ;
intptr_t WINAPI ChnconvStringEx ( const char *szSrcBuffer, char *szDstBuffer, int nSrcCodePage, int nDstCodePage, const CHNCONVEXINFO *pInfo, size_t nMaxLen ) ;
int WINAPI ChnconvCharEx ( int C, int nSrcCodePage, int nDstCodePage, const CHNCONVEXINFO *pInfo ) ;
int WINAPI IsChnconvValidCodePage ( int nSrcCodePage, int nDstCodePage ) ;
int WINAPI GetChnconvLastError ( void ) ;
int WINAPI AbortChnconv ( void ) ;
int WINAPI GetDllVersion ( void ) ;
// 屆偄娭悢
int WINAPI ChnconvA ( const char *szSrcFileName, const char *szDstFileName, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
int WINAPI ChnconvW ( const wchar_t *szSrcFileName, const wchar_t *szDstFileName, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
intptr_t WINAPI ChnconvString ( const char *szSrcBuffer, char *szDstBuffer, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode, size_t nMaxLen ) ;
int WINAPI ChnconvChar ( int C, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
int WINAPI IsAvailableCodePage ( int nSrcCodePage, int nDstCodePage ) ;
int WINAPI PrintFileStartA ( int nDstCodePage, const char *szDstFileName ) ;
int WINAPI PrintFileStartW ( int nDstCodePage, const wchar_t *szDstFileName ) ;
int WINAPI PrintFileEndA ( int nDstCodePage, const char *szDstFileName ) ;
int WINAPI PrintFileEndW ( int nDstCodePage, const wchar_t *szDstFileName ) ;
intptr_t WINAPI PrintFileStartString ( int nDstCodePage, char *szDstBuffer, size_t nMaxLen ) ;
intptr_t WINAPI PrintFileEndString ( int nDstCodePage, char *szDstBuffer, size_t nMaxLen ) ;
int WINAPI SetFontName ( const char *szGb, const char *szGbGothic, const char *szBig5, const char *szBig5Gothic ) ;
int WINAPI SetGbFontName ( const char *szGbFont, const char *szGbGothicFont ) ;
int WINAPI SetBig5FontName ( const char *szBig5Font, const char *szBig5GothicFont ) ;
int WINAPI SetPinyinFontName ( const char *szPinyinFont, const char *szPinyinGothicFont ) ;
int WINAPI SetUserDefinition ( int nSrcCodePage, int nDstCodePage, int cSrcChar, int cDstChar ) ;
int WINAPI SetTmFontSize ( int nNewFontSize ) ;
int WINAPI SetTmPropMode ( unsigned long dwNewPropMode ) ;
int WINAPI SetTmAsciiFontChar ( int C ) ;
int WINAPI SetChnconvWindow ( HWND hWnd, int IsDialog ) ;
int WINAPI Chnconv ( const void *szSrcFileName, const void *szDstFileName, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
int WINAPI PrintFileStart ( int nDstCodePage, void *pReserved ) ;
int WINAPI PrintFileEnd ( void *pReserved ) ;
#else
// 怴偟偄娭悢
typedef int ( WINAPI *CHNCONVEXA ) ( const char *szSrcFileName, const char *szDstFileName, int nSrcCodePage, int nDstCodePage, const CHNCONVEXINFO *pInfo ) ;
typedef int ( WINAPI *CHNCONVEXW ) ( const wchar_t *szSrcFileName, const wchar_t *szDstFileName, int nSrcCodePage, int nDstCodePage, const CHNCONVEXINFO *pInfo ) ;
typedef intptr_t ( WINAPI *CHNCONVSTRINGEX ) ( const char *szSrcBuffer, char *szDstBuffer, int nSrcCodePage, int nDstCodePage, const CHNCONVEXINFO *pInfo, size_t nMaxLen ) ;
typedef int ( WINAPI *CHNCONVCHAREX ) ( int C, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
typedef int ( WINAPI *ISCHNCONVVALIDCODEPAGE ) ( int nSrcCodePage, int nDstCodePage ) ;
typedef int ( WINAPI *GETCHNCONVLASTERROR ) ( void ) ;
typedef int ( WINAPI *ABORTCHNCONV ) ( void ) ;
typedef int ( WINAPI *GETDLLVERSION ) ( void ) ;
// 屆偄娭悢
typedef int ( WINAPI *CHNCONVA ) ( const char *szSrcFileName, const char *szDstFileName, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
typedef int ( WINAPI *CHNCONVW ) ( const wchar_t *szSrcFileName, const wchar_t *szDstFileName, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
typedef intptr_t ( WINAPI *CHNCONVSTRING ) ( const char *szSrcBuffer, char *szDstBuffer, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode, size_t nMaxLen ) ;
typedef int ( WINAPI *CHNCONVCHAR ) ( int C, int nSrcCodePage, int nDstCodePage, unsigned long dwConversionMode ) ;
typedef int ( WINAPI *PRINTFILESTARTA ) ( int nDstCodePage, const char *szDstFileName ) ;
typedef int ( WINAPI *PRINTFILESTARTW ) ( int nDstCodePage, const wchar_t *szDstFileName ) ;
typedef int ( WINAPI *PRINTFILEENDA ) ( int nDstCodePage, const char *szDstFileName ) ;
typedef int ( WINAPI *PRINTFILEENDW ) ( int nDstCodePage, const wchar_t *szDstFileName ) ;
typedef int ( WINAPI *SETGBFONTNAME ) ( const char *szGbFont, const char *szGbGothicFont ) ;
typedef int ( WINAPI *SETBIG5FONTNAME ) ( const char *szBig5Font, const char *szBig5GothicFont ) ;
typedef int ( WINAPI *SETPINYINFONTNAME ) ( const char *szPinyinFont, const char *szPinyinGothicFont ) ;
typedef int ( WINAPI *SETTMFONTSIZE ) ( int nNewFontSize ) ;
typedef int ( WINAPI *SETUSERDEFINITION ) ( int nSrcCodePage, int nDstCodePage, int cSrcChar, int cDstChar ) ;
typedef int ( WINAPI *SETTMPROPMODE ) ( unsigned long dwNewPropMode ) ;
typedef int ( WINAPI *SETTMASCIIFONTCHAR ) ( int C ) ;
typedef int ( WINAPI *SETCHNCONVWINDOW ) ( HWND hWnd, int IsDialog ) ;
#endif // #ifdef CHNCONV_DLL
////////////////////////////////////////////
// 撪晹偺峔憿懱 //
////////////////////////////////////////////
#ifdef CHNCONV_DLL
typedef struct {
int nFontSize ;
short nAsciiFont ;
short nAsciiGothicFont ;
short nCourierFont ;
short nJapaneseFont ;
short nJapaneseGothicFont ;
short nChineseFont ;
short nChineseGothicFont ;
short nChineseFantiFont ;
short nChineseFantiGothicFont ;
short nCw7Font ;
short nCw7GothicFont ;
short nCw7FantiFont ;
short nCw7FantiGothicFont ;
} TMDATA ;
typedef struct {
STREAM *StreamIn ;
STREAM *StreamOut ;
int nSrcCodePage ;
int nDstCodePage ;
unsigned long dwConversionMode ;
unsigned long dwAdditionalMode ;
int nError ;
// TXT
short nEncodeMode ;
STOREDCHARSA *CharRefBuffer ;
STOREDCHARSW *CharRefUnreadBuffer ;
// RTF
const char *szGbFont ;
const char *szGbGothicFont ;
const char *szBig5Font ;
const char *szBig5GothicFont ;
const char *szPinyinFont ;
const char *szPinyinGothicFont ;
// TM
TMDATA *tm ;
// User-Defined Conversion
const CHNCONV_USERDEF *pSrcToDst ;
size_t nNumberOfSrcToDst ;
const CHNCONV_USERDEF *pSrcToUc ;
size_t nNumberOfSrcToUc ;
// PeekMessageProc
HWND hDialog ;
short IsPeekMessageUnicode ;
// Reserved
unsigned long dwReserved ;
} CHNCONVDATA ;
int SetChnconvLastError ( int nError ) ;
#endif // #ifdef CHNCONV_DLL
////////////////////////////////////////////
// 偦偺懠 //
////////////////////////////////////////////
#if defined CHNCONV_DLL || defined CHNCONV_EXE || defined CHNCONV_COM || defined SETUP_C
// 僶僢僼傽偺挿偝
#define FONTNAME_MAX LF_FACESIZE
#define UNMAPPABLE_CHAR_FORMAT_MAX 0x100
// 昗弨偺弌椡僼僅儞僩僒僀僘
#define DEFAULT_FONT_SIZE 21
// 昗弨偺弌椡僼僅儞僩柤
#define DEFAULT_GB_FONT "SimSun"
#define DEFAULT_GB_GOTHIC_FONT "SimHei"
#define DEFAULT_BIG5_FONT "MingLiU"
#define DEFAULT_BIG5_GOTHIC_FONT DEFAULT_BIG5_FONT
#define DEFAULT_PINYIN_FONT "Times New Roman"
#define DEFAULT_PINYIN_GOTHIC_FONT "Arial"
#define DEFAULT_COURIER_FONT "Courier New"
// 昗弨偺弌椡僼僅儞僩柤乮儘乕僇儖柤乯
#define DEFAULT_GB_FONT_L "\xCB\xCE\xCC\xE5"
#define DEFAULT_GB_GOTHIC_FONT_L "\xBA\xDA\xCC\xE5"
#define DEFAULT_BIG5_FONT_L "\xB2\xD3\xA9\xFA\xC5\xE9"
#define DEFAULT_BIG5_GOTHIC_FONT_L DEFAULT_BIG5_FONT_L
#endif
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -