unicode编码有大端小端,用两个字节表示,用大端编码时,要把低位数据是字符编码的高字节,高字节是字符编码的高字节,文本头为FE FF,
#include <config.h>
#include <encoding_manager.h>
#include <string.h>
static int isUtf16beCoding(unsigned char *pucBufHead);
static int Utf16beGetCodeFrmBuf(unsigned char *pucBufStart, unsigned char *pucBufEnd, unsigned int *pdwCode);
static T_EncodingOpr g_tUtf16beEncodingOpr = {
.name = "utf-16be",
.iHeadLen = 2,
.isSupport = isUtf16beCoding,
.GetCodeFrmBuf = Utf16beGetCodeFrmBuf,
};
static int isUtf16beCoding(unsigned char *pucBufHead)
{
const char aStrUtf16be[] = {0xFE, 0xFF, 0};//文本头
if (strncmp((const char*)pucBufHead, aStrUtf16be, 2) == 0)//是不是unicode的文本头
{
/* UTF-16 big endian */
return 1;
}
else
{
return 0;
}
}
static int Utf16beGetCodeFrmBuf(unsigned char *pucBufStart, unsigned char *pucBufEnd, unsigned int *p