亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? encoding.c

?? ReactOS是一些高手根據Windows XP的內核編寫出的類XP。內核實現機理和API函數調用幾乎相同。甚至可以兼容XP的程序。喜歡研究系統內核的人可以看一看。
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
 * encoding.c : implements the encoding conversion functions needed for XML
 *
 * Related specs: 
 * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies
 * rfc2781        UTF-16, an encoding of ISO 10646, P. Hoffman, F. Yergeau
 * [ISO-10646]    UTF-8 and UTF-16 in Annexes
 * [ISO-8859-1]   ISO Latin-1 characters codes.
 * [UNICODE]      The Unicode Consortium, "The Unicode Standard --
 *                Worldwide Character Encoding -- Version 1.0", Addison-
 *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is
 *                described in Unicode Technical Report #4.
 * [US-ASCII]     Coded Character Set--7-bit American Standard Code for
 *                Information Interchange, ANSI X3.4-1986.
 *
 * See Copyright for the status of this software.
 *
 * daniel@veillard.com
 *
 * Original code for IsoLatin1 and UTF-16 by "Martin J. Duerst" <duerst@w3.org>
 */

#define IN_LIBXML
#include "libxml.h"

#include <string.h>

#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef LIBXML_ICONV_ENABLED
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#endif
#include <libxml/encoding.h>
#include <libxml/xmlmemory.h>
#ifdef LIBXML_HTML_ENABLED
#include <libxml/HTMLparser.h>
#endif
#include <libxml/globals.h>
#include <libxml/xmlerror.h>

static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;

typedef struct _xmlCharEncodingAlias xmlCharEncodingAlias;
typedef xmlCharEncodingAlias *xmlCharEncodingAliasPtr;
struct _xmlCharEncodingAlias {
    const char *name;
    const char *alias;
};

static xmlCharEncodingAliasPtr xmlCharEncodingAliases = NULL;
static int xmlCharEncodingAliasesNb = 0;
static int xmlCharEncodingAliasesMax = 0;

#ifdef LIBXML_ICONV_ENABLED
#if 0
#define DEBUG_ENCODING  /* Define this to get encoding traces */
#endif
#else
#ifdef LIBXML_ISO8859X_ENABLED
static void xmlRegisterCharEncodingHandlersISO8859x (void);
#endif
#endif

static int xmlLittleEndian = 1;


/************************************************************************
 *									*
 *		Conversions To/From UTF8 encoding			*
 *									*
 ************************************************************************/

/**
 * asciiToUTF8:
 * @out:  a pointer to an array of bytes to store the result
 * @outlen:  the length of @out
 * @in:  a pointer to an array of ASCII chars
 * @inlen:  the length of @in
 *
 * Take a block of ASCII chars in and try to convert it to an UTF-8
 * block of chars out.
 * Returns 0 if success, or -1 otherwise
 * The value of @inlen after return is the number of octets consumed
 *     if the return value is positive, else unpredictable.
 * The value of @outlen after return is the number of octets consumed.
 */
static int
asciiToUTF8(unsigned char* out, int *outlen,
              const unsigned char* in, int *inlen) {
    unsigned char* outstart = out;
    const unsigned char* base = in;
    const unsigned char* processed = in;
    unsigned char* outend = out + *outlen;
    const unsigned char* inend;
    unsigned int c;
    int bits;

    inend = in + (*inlen);
    while ((in < inend) && (out - outstart + 5 < *outlen)) {
	c= *in++;

	/* assertion: c is a single UTF-4 value */
        if (out >= outend)
	    break;
        if      (c <    0x80) {  *out++=  c;                bits= -6; }
        else { 
	    *outlen = out - outstart;
	    *inlen = processed - base;
	    return(-1);
	}
 
        for ( ; bits >= 0; bits-= 6) {
            if (out >= outend)
	        break;
            *out++= ((c >> bits) & 0x3F) | 0x80;
        }
	processed = (const unsigned char*) in;
    }
    *outlen = out - outstart;
    *inlen = processed - base;
    return(*outlen);
}

#ifdef LIBXML_OUTPUT_ENABLED
/**
 * UTF8Toascii:
 * @out:  a pointer to an array of bytes to store the result
 * @outlen:  the length of @out
 * @in:  a pointer to an array of UTF-8 chars
 * @inlen:  the length of @in
 *
 * Take a block of UTF-8 chars in and try to convert it to an ASCII
 * block of chars out.
 *
 * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
 * The value of @inlen after return is the number of octets consumed
 *     if the return value is positive, else unpredictable.
 * The value of @outlen after return is the number of octets consumed.
 */
static int
UTF8Toascii(unsigned char* out, int *outlen,
              const unsigned char* in, int *inlen) {
    const unsigned char* processed = in;
    const unsigned char* outend;
    const unsigned char* outstart = out;
    const unsigned char* instart = in;
    const unsigned char* inend;
    unsigned int c, d;
    int trailing;

    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
    if (in == NULL) {
        /*
	 * initialization nothing to do
	 */
	*outlen = 0;
	*inlen = 0;
	return(0);
    }
    inend = in + (*inlen);
    outend = out + (*outlen);
    while (in < inend) {
	d = *in++;
	if      (d < 0x80)  { c= d; trailing= 0; }
	else if (d < 0xC0) {
	    /* trailing byte in leading position */
	    *outlen = out - outstart;
	    *inlen = processed - instart;
	    return(-2);
        } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
        else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
        else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
	else {
	    /* no chance for this in Ascii */
	    *outlen = out - outstart;
	    *inlen = processed - instart;
	    return(-2);
	}

	if (inend - in < trailing) {
	    break;
	} 

	for ( ; trailing; trailing--) {
	    if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
		break;
	    c <<= 6;
	    c |= d & 0x3F;
	}

	/* assertion: c is a single UTF-4 value */
	if (c < 0x80) {
	    if (out >= outend)
		break;
	    *out++ = c;
	} else {
	    /* no chance for this in Ascii */
	    *outlen = out - outstart;
	    *inlen = processed - instart;
	    return(-2);
	}
	processed = in;
    }
    *outlen = out - outstart;
    *inlen = processed - instart;
    return(*outlen);
}
#endif /* LIBXML_OUTPUT_ENABLED */

/**
 * isolat1ToUTF8:
 * @out:  a pointer to an array of bytes to store the result
 * @outlen:  the length of @out
 * @in:  a pointer to an array of ISO Latin 1 chars
 * @inlen:  the length of @in
 *
 * Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8
 * block of chars out.
 * Returns the number of bytes written if success, or -1 otherwise
 * The value of @inlen after return is the number of octets consumed
 *     if the return value is positive, else unpredictable.
 * The value of @outlen after return is the number of octets consumed.
 */
int
isolat1ToUTF8(unsigned char* out, int *outlen,
              const unsigned char* in, int *inlen) {
    unsigned char* outstart = out;
    const unsigned char* base = in;
    unsigned char* outend;
    const unsigned char* inend;
    const unsigned char* instop;

    if ((out == NULL) || (in == NULL) || (outlen == NULL) || (inlen == NULL))
	return(-1);

    outend = out + *outlen;
    inend = in + (*inlen);
    instop = inend;
    
    while (in < inend && out < outend - 1) {
    	if (*in >= 0x80) {
	    *out++ = (((*in) >>  6) & 0x1F) | 0xC0;
        *out++ = ((*in) & 0x3F) | 0x80;
	    ++in;
	}
	if (instop - in > outend - out) instop = in + (outend - out); 
	while (in < instop && *in < 0x80) {
	    *out++ = *in++;
	}
    }	
    if (in < inend && out < outend && *in < 0x80) {
        *out++ = *in++;
    }
    *outlen = out - outstart;
    *inlen = in - base;
    return(*outlen);
}

/**
 * UTF8ToUTF8:
 * @out:  a pointer to an array of bytes to store the result
 * @outlen:  the length of @out
 * @inb:  a pointer to an array of UTF-8 chars
 * @inlenb:  the length of @in in UTF-8 chars
 *
 * No op copy operation for UTF8 handling.
 *
 * Returns the number of bytes written, or -1 if lack of space.
 *     The value of *inlen after return is the number of octets consumed
 *     if the return value is positive, else unpredictable.
 */
static int
UTF8ToUTF8(unsigned char* out, int *outlen,
           const unsigned char* inb, int *inlenb)
{
    int len;

    if ((out == NULL) || (inb == NULL) || (outlen == NULL) || (inlenb == NULL))
	return(-1);
    if (*outlen > *inlenb) {
	len = *inlenb;
    } else {
	len = *outlen;
    }
    if (len < 0)
	return(-1);

    memcpy(out, inb, len);

    *outlen = len;
    *inlenb = len;
    return(*outlen);
}


#ifdef LIBXML_OUTPUT_ENABLED
/**
 * UTF8Toisolat1:
 * @out:  a pointer to an array of bytes to store the result
 * @outlen:  the length of @out
 * @in:  a pointer to an array of UTF-8 chars
 * @inlen:  the length of @in
 *
 * Take a block of UTF-8 chars in and try to convert it to an ISO Latin 1
 * block of chars out.
 *
 * Returns the number of bytes written if success, -2 if the transcoding fails,
           or -1 otherwise
 * The value of @inlen after return is the number of octets consumed
 *     if the return value is positive, else unpredictable.
 * The value of @outlen after return is the number of octets consumed.
 */
int
UTF8Toisolat1(unsigned char* out, int *outlen,
              const unsigned char* in, int *inlen) {
    const unsigned char* processed = in;
    const unsigned char* outend;
    const unsigned char* outstart = out;
    const unsigned char* instart = in;
    const unsigned char* inend;
    unsigned int c, d;
    int trailing;

    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
    if (in == NULL) {
        /*
	 * initialization nothing to do
	 */
	*outlen = 0;
	*inlen = 0;
	return(0);
    }
    inend = in + (*inlen);
    outend = out + (*outlen);
    while (in < inend) {
	d = *in++;
	if      (d < 0x80)  { c= d; trailing= 0; }
	else if (d < 0xC0) {
	    /* trailing byte in leading position */
	    *outlen = out - outstart;
	    *inlen = processed - instart;
	    return(-2);
        } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
        else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
        else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
	else {
	    /* no chance for this in IsoLat1 */
	    *outlen = out - outstart;
	    *inlen = processed - instart;
	    return(-2);
	}

	if (inend - in < trailing) {
	    break;
	} 

	for ( ; trailing; trailing--) {
	    if (in >= inend)
		break;
	    if (((d= *in++) & 0xC0) != 0x80) {
		*outlen = out - outstart;
		*inlen = processed - instart;
		return(-2);
	    }
	    c <<= 6;
	    c |= d & 0x3F;
	}

	/* assertion: c is a single UTF-4 value */
	if (c <= 0xFF) {
	    if (out >= outend)
		break;
	    *out++ = c;
	} else {
	    /* no chance for this in IsoLat1 */
	    *outlen = out - outstart;
	    *inlen = processed - instart;
	    return(-2);
	}
	processed = in;
    }
    *outlen = out - outstart;
    *inlen = processed - instart;
    return(*outlen);
}
#endif /* LIBXML_OUTPUT_ENABLED */

/**
 * UTF16LEToUTF8:
 * @out:  a pointer to an array of bytes to store the result
 * @outlen:  the length of @out
 * @inb:  a pointer to an array of UTF-16LE passwd as a byte array
 * @inlenb:  the length of @in in UTF-16LE chars
 *
 * Take a block of UTF-16LE ushorts in and try to convert it to an UTF-8
 * block of chars out. This function assumes the endian property
 * is the same between the native type of this machine and the
 * inputed one.
 *
 * Returns the number of bytes written, or -1 if lack of space, or -2
 *     if the transcoding fails (if *in is not a valid utf16 string)
 *     The value of *inlen after return is the number of octets consumed
 *     if the return value is positive, else unpredictable.
 */
static int
UTF16LEToUTF8(unsigned char* out, int *outlen,
            const unsigned char* inb, int *inlenb)
{
    unsigned char* outstart = out;
    const unsigned char* processed = inb;
    unsigned char* outend = out + *outlen;
    unsigned short* in = (unsigned short*) inb;
    unsigned short* inend;
    unsigned int c, d, inlen;
    unsigned char *tmp;
    int bits;

    if ((*inlenb % 2) == 1)
        (*inlenb)--;
    inlen = *inlenb / 2;
    inend = in + inlen;
    while ((in < inend) && (out - outstart + 5 < *outlen)) {
        if (xmlLittleEndian) {
	    c= *in++;
	} else {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人激情免费网站| 日韩一区二区精品葵司在线| 欧美三日本三级三级在线播放| 日韩欧美国产精品| 中文字幕va一区二区三区| 一区二区高清免费观看影视大全| 日韩 欧美一区二区三区| 麻豆国产一区二区| 欧美色精品在线视频| 精品久久久久久久久久久院品网 | 一区二区在线观看免费视频播放| 国产精品国模大尺度视频| 天堂成人国产精品一区| 粉嫩av一区二区三区在线播放| 欧美日韩在线亚洲一区蜜芽| 欧美国产禁国产网站cc| 日本欧美肥老太交大片| 欧美日韩国产一区二区三区地区| 久久亚洲精精品中文字幕早川悠里| 国产欧美一区二区三区鸳鸯浴| 久久99精品一区二区三区三区| 色综合久久九月婷婷色综合| 国产精品视频观看| 国产一区二区视频在线播放| 欧美日韩国产一二三| 亚洲国产美国国产综合一区二区| 国产99一区视频免费| 久久午夜国产精品| 麻豆传媒一区二区三区| 欧美性xxxxxxxx| 色综合视频在线观看| 国产亚洲1区2区3区| 国产精品一区二区91| 日韩欧美亚洲国产另类| 六月丁香婷婷久久| 日韩午夜av一区| 亚洲曰韩产成在线| 色综合久久中文综合久久97| 国产精品美女一区二区| 成人禁用看黄a在线| 久久久久国产一区二区三区四区| 激情文学综合插| 精品久久久久久久一区二区蜜臀| 免费高清不卡av| 日韩精品最新网址| 麻豆精品久久久| 欧美日韩中文字幕一区二区| 亚洲成人激情社区| 欧美日韩黄色影视| 久久国产精品99久久人人澡| 日韩一区二区三区在线| 亚洲天堂成人在线观看| 欧美手机在线视频| 天天影视涩香欲综合网 | 91网站视频在线观看| 亚洲永久精品国产| 欧美精品日韩综合在线| 日韩精彩视频在线观看| 久久久久久久久97黄色工厂| 成人免费毛片片v| 亚洲一区二区视频| 91精品国产aⅴ一区二区| 亚洲视频一二三| 日韩一区二区免费电影| 国产69精品久久777的优势| 夜夜操天天操亚洲| 91精品国产全国免费观看| 日本精品免费观看高清观看| 亚洲1区2区3区4区| 欧美大片在线观看| 91在线观看地址| 性做久久久久久免费观看| 欧美中文字幕亚洲一区二区va在线 | 久久久美女艺术照精彩视频福利播放| 国产一区二区91| 亚洲精品高清在线| 欧美v国产在线一区二区三区| 国产一区二三区好的| av不卡免费电影| 老司机午夜精品99久久| 国产精品久久免费看| 日韩区在线观看| 99久久99久久久精品齐齐| 久久久精品tv| 69成人精品免费视频| 国产福利一区二区三区视频| 日韩主播视频在线| 国产精品国产自产拍在线| 欧美三级日韩三级| 国产成人在线色| 午夜精品久久久久久久久| 日本一区二区三区电影| 99久久伊人精品| 老司机精品视频线观看86| 中文字幕一区二区三区蜜月| 欧美一级视频精品观看| 99久久婷婷国产综合精品| 成人精品一区二区三区中文字幕| 丝袜诱惑制服诱惑色一区在线观看 | 欧美一区二区三区视频免费| 欧美在线一二三| 国产成人精品影院| 国产日韩av一区| 国产日本一区二区| 日韩一区二区精品| 日韩一级二级三级| 欧美色精品在线视频| 91精品91久久久中77777| 粉嫩av亚洲一区二区图片| 久久国产精品一区二区| 免费高清不卡av| 日本伊人色综合网| 天天操天天综合网| 亚洲尤物视频在线| 久久精品视频在线看| 久久免费偷拍视频| 欧美mv日韩mv亚洲| 国产亚洲精品超碰| 久久久久久一二三区| 国产精品热久久久久夜色精品三区| 精品欧美一区二区久久| 欧美电影在线免费观看| 欧美影院一区二区| 欧美午夜寂寞影院| 亚洲日本护士毛茸茸| 国产精品毛片无遮挡高清| 亚洲欧美综合色| 亚洲天堂网中文字| 五月婷婷综合激情| 麻豆国产欧美日韩综合精品二区 | 亚洲欧洲精品一区二区三区不卡| 国产精品免费视频网站| 中文字幕不卡在线播放| 国产精品久久久久永久免费观看 | 久久精品在线免费观看| 欧美高清一级片在线观看| 国产欧美日韩精品在线| 亚洲同性gay激情无套| 亚洲一区二三区| 午夜精品一区在线观看| 国产精品一二三四区| 成人av在线一区二区三区| 欧美特级限制片免费在线观看| 欧美性大战久久| 精品国精品国产| 欧美国产视频在线| 国产亚洲精久久久久久| 亚洲永久免费av| 蜜桃精品视频在线| 成人avav影音| 欧美午夜精品理论片a级按摩| 精品少妇一区二区三区视频免付费| 欧美成人精品高清在线播放| 精品少妇一区二区三区| 日韩伦理免费电影| 日本中文字幕不卡| 99国产精品视频免费观看| 欧美三级日韩三级国产三级| 国产欧美精品一区二区色综合朱莉| 国产精品久久久久久妇女6080| 欧美成人a视频| 亚洲激情成人在线| 蜜臀av性久久久久av蜜臀妖精| 本田岬高潮一区二区三区| 欧美日韩一区二区三区不卡 | 欧美喷潮久久久xxxxx| 久久久久久**毛片大全| 一区二区三区精品在线观看| 国产精品伊人色| 日本乱人伦aⅴ精品| 亚洲国产精品v| 热久久免费视频| 成人激情开心网| 欧美一级片在线看| 久久免费视频一区| 男女男精品视频网| 日本韩国视频一区二区| 欧美激情综合在线| 日韩激情视频在线观看| 91国模大尺度私拍在线视频| 2023国产一二三区日本精品2022| 中文字幕亚洲区| 国产九九视频一区二区三区| 欧美性做爰猛烈叫床潮| 亚洲免费av网站| 国产成人综合网| 久久精品视频免费| 日韩中文字幕亚洲一区二区va在线| 欧美无砖砖区免费| 中文字幕欧美日本乱码一线二线| 狠狠色2019综合网| 欧美吻胸吃奶大尺度电影| 一本大道久久a久久精二百| 国产夜色精品一区二区av| 日韩电影免费在线看| 一区二区在线观看视频| 成人美女视频在线观看18| 久久精品视频一区| 精品一区二区影视| 精品国产一二三|