亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
蜜桃一区二区三区在线观看| 风间由美一区二区三区在线观看 | 亚洲成人激情社区| 中文字幕乱码日本亚洲一区二区| 精品国产一区二区三区久久影院| 精品国产一区二区三区久久影院| 日韩毛片高清在线播放| 亚洲天堂2014| 国产在线精品一区二区三区不卡| 免费av成人在线| 久久99在线观看| 亚洲精品成人a在线观看| 成人av午夜电影| 成人精品国产福利| 91麻豆精品国产无毒不卡在线观看| 在线免费视频一区二区| 91蝌蚪porny成人天涯| 一本色道久久综合亚洲精品按摩| 欧美主播一区二区三区| 国产精品无人区| 一区二区三区毛片| 日本欧美加勒比视频| 国产美女久久久久| 91精品国产美女浴室洗澡无遮挡| 久久综合久久久久88| 久久久久久99久久久精品网站| 国产清纯在线一区二区www| 亚洲欧洲精品一区二区精品久久久 | 日韩精品专区在线| 91麻豆国产香蕉久久精品| 久久先锋影音av| 男人的天堂久久精品| 欧美一区二区三区在线| 亚洲一区免费观看| 亚洲国产wwwccc36天堂| 成人黄色一级视频| 国产精品三级电影| 国产福利一区二区三区视频| 成人a区在线观看| 久久久精品影视| 成人福利在线看| 久久久久久9999| 91网站视频在线观看| 国产日韩欧美麻豆| 成人午夜电影网站| 日韩一级完整毛片| 亚洲一区二区四区蜜桃| 91在线视频官网| 国产亲近乱来精品视频| 国内精品伊人久久久久影院对白| 色成人在线视频| 亚洲综合在线电影| 在线综合亚洲欧美在线视频| 一二三四区精品视频| 欧美视频在线观看一区| 精品久久久三级丝袜| 一区二区三区在线观看欧美| 久久草av在线| 日韩午夜在线影院| 成人理论电影网| 一区二区三区四区激情| 91麻豆免费看片| 日本不卡高清视频| 久久久久国产精品麻豆| 色综合久久中文字幕综合网 | 三级成人在线视频| 成人性生交大片免费看中文网站| 久久综合色一综合色88| 91亚洲精品一区二区乱码| 亚洲蜜臀av乱码久久精品| 欧美三级韩国三级日本一级| 中文字幕亚洲精品在线观看| 国内精品在线播放| 国产精品灌醉下药二区| 色视频成人在线观看免| 日韩精品免费视频人成| 26uuu成人网一区二区三区| 国产不卡在线视频| 亚洲男人的天堂在线观看| 5858s免费视频成人| 国产精品18久久久| 夜夜精品浪潮av一区二区三区| 欧美日韩成人在线一区| 国产一区二区三区在线观看精品| 精品入口麻豆88视频| 亚洲高清免费视频| 日韩三级视频在线观看| 成人黄色国产精品网站大全在线免费观看 | 亚洲日本在线天堂| 欧美一二三区在线观看| 99免费精品视频| 亚洲视频一二三| 3atv在线一区二区三区| 国产91精品在线观看| 青青草97国产精品免费观看 | 国产在线精品免费av| 夜夜精品浪潮av一区二区三区| 日韩精品中午字幕| 在线观看亚洲a| 国产剧情一区二区三区| 国产成人在线视频网址| 九色综合国产一区二区三区| 色播五月激情综合网| 国产一区二区三区四区在线观看| 亚洲品质自拍视频| 国产片一区二区三区| 精品国产91乱码一区二区三区| 91精品91久久久中77777| 成人中文字幕在线| 蜜臀av一区二区| 悠悠色在线精品| 国产色爱av资源综合区| 精品久久久久久最新网址| 欧美高清精品3d| 一区二区免费在线播放| 欧美激情一二三区| 国产亚洲自拍一区| 日韩精品一区二区三区三区免费| 欧美视频一区二区三区在线观看| 99精品1区2区| www.欧美.com| 成人免费看黄yyy456| 不卡欧美aaaaa| 成人精品免费看| 东方欧美亚洲色图在线| 精品中文字幕一区二区小辣椒| 日韩影视精彩在线| 亚洲6080在线| 亚洲国产精品久久人人爱蜜臀| 中文字幕日本不卡| 亚洲人吸女人奶水| 亚洲日穴在线视频| 依依成人精品视频| 亚洲精品欧美综合四区| 一区二区三区国产豹纹内裤在线 | 国产乱国产乱300精品| 亚洲色图制服丝袜| 一区二区三区精密机械公司| 亚洲综合另类小说| 国产精品久久午夜| 天堂一区二区在线免费观看| 婷婷丁香久久五月婷婷| 日本成人在线网站| 国产一区免费电影| 不卡av电影在线播放| 91最新地址在线播放| 三级一区在线视频先锋 | 中文字幕一区二区三区色视频| 国产精品每日更新| 日韩毛片视频在线看| 亚洲精品国产一区二区三区四区在线| 国产精品久久久久久久岛一牛影视| 亚洲欧美综合在线精品| 国产精品嫩草影院com| 国产色产综合色产在线视频| 18成人在线观看| 日韩精品1区2区3区| 激情小说欧美图片| av激情成人网| 欧美日韩色综合| 2021中文字幕一区亚洲| 国产亚洲欧洲997久久综合| 亚洲视频 欧洲视频| 三级在线观看一区二区 | 精品免费国产二区三区 | 欧美日韩精品专区| 久久综合久色欧美综合狠狠| 亚洲欧美日韩国产另类专区| 亚洲一区在线电影| 精品无人区卡一卡二卡三乱码免费卡| 国产福利91精品| 欧美伊人精品成人久久综合97 | 久久免费精品国产久精品久久久久| 国产精品入口麻豆原神| 三级影片在线观看欧美日韩一区二区| 韩国v欧美v日本v亚洲v| 在线免费观看日本欧美| 久久综合狠狠综合久久综合88| 亚洲午夜久久久久| 国产福利一区二区三区| 欧美精品18+| 亚洲欧洲日韩av| 狠狠v欧美v日韩v亚洲ⅴ| 99久久99久久免费精品蜜臀| 久久毛片高清国产| 亚洲一区二区四区蜜桃| 春色校园综合激情亚洲| 欧美一级国产精品| 亚洲自拍偷拍综合| 成人小视频在线观看| 欧美一级黄色录像| 香蕉加勒比综合久久| 成人av综合在线| 久久综合九色欧美综合狠狠| 亚洲一区二区三区四区中文字幕| 一本大道久久a久久精品综合| 久久综合999| 日本不卡一区二区| 欧美三级韩国三级日本三斤 | 国产成人av福利|