为了使函数mxmlLoadFile、mxmlFindElement支持中文,需修改mxml源码两处:
/*
* 'mxml_file_getc()' - Get a character from a file.
*/
static int /* O - Character or EOF */
mxml_file_getc(void *p, /* I - Pointer to file */
int *encoding) /* IO - Encoding */
第四行,添加:
//--------------------------------------------------------------------------- added by wu.修改此处,为了支持中文。
return getc((FILE*)p);
//---------------------------------------------------------------------------
2.文件mxml-file.c中,在函数
/*
* 'mxml_add_char()' - Add a character to a buffer, expanding as needed.
*/
static int /* O - 0 on success, -1 on error */
mxml_add_char(int ch, /* I - Character to add */
char **bufptr, /* IO - Current position in buffer */
char **buffer, /* IO - Current buffer */
int *bufsize) /* IO - Current buffer size */
第27行,添加:
// ------------------------------------------------------------------------- added by wu, 为支持中文添加
*(*bufptr)++ = ch;
return (0);
// -------------------------------------------------------------------------
两处修改思路是相同的,都略过了字符编码的判断。