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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? encoding.c

?? Vovida 社區(qū)開源的 SIP 協(xié)議源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * encoding.c : implements the encoding conversion functions needed for XML * * Related specs:  * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies * [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. * * Original code for IsoLatin1 and UTF-16 by "Martin J. Duerst" <duerst@w3.org> * * See Copyright for the status of this software. * * Daniel.Veillard@w3.org */#include "global.h"#ifdef WIN32#include "win32config.h"#else#include "config.h"#endif#include <stdio.h>#include <string.h>#ifdef HAVE_CTYPE_H#include <ctype.h>#endif#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif#include <libxml/encoding.h>#include <libxml/xmlmemory.h>xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;/* * From rfc2044: encoding of the Unicode values on UTF-8: * * UCS-4 range (hex.)           UTF-8 octet sequence (binary) * 0000 0000-0000 007F   0xxxxxxx * 0000 0080-0000 07FF   110xxxxx 10xxxxxx * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx  * * I hope we won't use values > 0xFFFF anytime soon ! *//** * xmlCheckUTF8: Check utf-8 string for legality. * @utf: Pointer to putative utf-8 encoded string. * * Checks @utf for being valid utf-8. @utf is assumed to be * null-terminated. This function is not super-strict, as it will * allow longer utf-8 sequences than necessary. Note that Java is * capable of producing these sequences if provoked. Also note, this * routine checks for the 4-byte maxiumum size, but does not check for * 0x10ffff maximum value. * * Return value: true if @utf is valid. **/intxmlCheckUTF8(const unsigned char *utf){    int ix;    unsigned char c;    for (ix = 0; (c = utf[ix]);) {        if (c & 0x80) {	    if ((utf[ix + 1] & 0xc0) != 0x80)	        return(0);	    if ((c & 0xe0) == 0xe0) {	        if ((utf[ix + 2] & 0xc0) != 0x80)		    return(0);	        if ((c & 0xf0) == 0xf0) {		    if ((c & 0xf8) != 0xf0 || (utf[ix + 3] & 0xc0) != 0x80)		        return(0);		    ix += 4;		    /* 4-byte code */	        } else		  /* 3-byte code */		    ix += 3;	    } else	      /* 2-byte code */	        ix += 2;	} else	    /* 1-byte code */	    ix++;      }      return(1);}/** * 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 byte written, or -1 by lack of space. */intisolat1ToUTF8(unsigned char* out, int outlen,              const unsigned char* in, int *inlen) {    unsigned char* outstart= out;    unsigned char* outend= out+outlen;    const unsigned char* inend= in+*inlen;    unsigned char c;    while (in < inend) {        c= *in++;        if (c < 0x80) {            if (out >= outend)  return(-1);            *out++ = c;        }        else {            if (out >= outend)  return(-1);            *out++ = 0xC0 | (c >> 6);            if (out >= outend)  return(-1);            *out++ = 0x80 | (0x3F & c);        }    }    return(out-outstart);}/** * 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. * TODO: UTF8Toisolat1 need a fallback mechanism ... * * Returns the number of byte written, or -1 by lack of space, or -2 *     if the transcoding fails (for *in is not valid utf8 string or *     the result of transformation can't fit into the encoding we want) * The value of @inlen after return is the number of octets consumed *     as the return value is positive, else unpredictiable. */intUTF8Toisolat1(unsigned char* out, int outlen,              const unsigned char* in, int *inlen) {    unsigned char* outstart= out;    unsigned char* outend= out+outlen;    const unsigned char* inend= in+*inlen;    unsigned char c;    while (in < inend) {        c= *in++;        if (c < 0x80) {            if (out >= outend)  return(-1);            *out++= c;        }	else if (in == inend) {            *inlen -= 1;            break;	}	else if (((c & 0xFC) == 0xC0) && ((*in & 0xC0) == 0x80)) {	    /* a two byte utf-8 and can be encoding as isolate1 */            *out++= ((c & 0x03) << 6) | (*in++ & 0x3F);	}	else	    return(-2);	/* TODO : some should be represent as "&#x____;" */    }    return(out-outstart);}/** * 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 assume the endian properity * is the same between the native type of this machine and the * inputed one. * * Returns the number of byte written, or -1 by lack of space, or -2 *     if the transcoding fails (for *in is not valid utf16 string) *     The value of *inlen after return is the number of octets consumed *     as the return value is positive, else unpredictiable. */intUTF16LEToUTF8(unsigned char* out, int outlen,            const unsigned char* inb, int *inlenb){    unsigned char* outstart= out;    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) {#ifdef BIG_ENDIAN	tmp = (unsigned char *) in;	c = *tmp++;	c = c | (((unsigned int)*tmp) << 8);	in++;#else /* BIG_ENDIAN */        c= *in++;#endif /* BIG_ENDIAN */        if ((c & 0xFC00) == 0xD800) {    /* surrogates */            if (in >= inend) {           /* (in > inend) shouldn't happens */                (*inlenb) -= 2;                break;            }#ifdef BIG_ENDIAN            tmp = (unsigned char *) in;            d = *tmp++;	    d = d | (((unsigned int)*tmp) << 8);	    in++;#else /* BIG_ENDIAN */            d = *in++;#endif /* BIG_ENDIAN */            if ((d & 0xFC00) == 0xDC00) {                c &= 0x03FF;                c <<= 10;                c |= d & 0x03FF;                c += 0x10000;            }            else	        return(-2);        }	/* assertion: c is a single UTF-4 value */        if (out >= outend)	    return(-1);        if      (c <    0x80) {  *out++=  c;                bits= -6; }        else if (c <   0x800) {  *out++= ((c >>  6) & 0x1F) | 0xC0;  bits=  0; }        else if (c < 0x10000) {  *out++= ((c >> 12) & 0x0F) | 0xE0;  bits=  6; }        else                  {  *out++= ((c >> 18) & 0x07) | 0xF0;  bits= 12; }         for ( ; bits >= 0; bits-= 6) {            if (out >= outend)	        return(-1);            *out++= ((c >> bits) & 0x3F) | 0x80;        }    }    return(out-outstart);}/** * UTF8ToUTF16LE: * @outb:  a pointer to an array of bytes to store the result * @outlen:  the length of @outb * @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 UTF-16LE * block of chars out. * TODO: UTF8ToUTF16LE need a fallback mechanism ... * * Returns the number of byte written, or -1 by lack of space, or -2 *     if the transcoding failed.  */intUTF8ToUTF16LE(unsigned char* outb, int outlen,            const unsigned char* in, int *inlen){    unsigned short* out = (unsigned short*) outb;    unsigned short* outstart= out;    unsigned short* outend;    const unsigned char* inend= in+*inlen;    unsigned int c, d, trailing;#ifdef BIG_ENDIAN    unsigned char *tmp;    unsigned short tmp1, tmp2;#endif /* BIG_ENDIAN */    outlen /= 2; /* convert in short length */    outend = out + outlen;    while (in < inend) {      d= *in++;      if      (d < 0x80)  { c= d; trailing= 0; }      else if (d < 0xC0)          return(-2);    /* trailing byte in leading position */      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          return(-2);    /* no chance for this in UTF-16 */      if (inend - in < trailing) {          *inlen -= (inend - in);          break;      }       for ( ; trailing; trailing--) {          if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))	      return(-1);          c <<= 6;          c |= d & 0x3F;      }      /* assertion: c is a single UTF-4 value */        if (c < 0x10000) {            if (out >= outend)	        return(-1);#ifdef BIG_ENDIAN            tmp = (unsigned char *) out;            *tmp = c ;            *(tmp + 1) = c >> 8 ;            out++;#else /* BIG_ENDIAN */            *out++ = c;#endif /* BIG_ENDIAN */        }        else if (c < 0x110000) {            if (out+1 >= outend)	        return(-1);            c -= 0x10000;#ifdef BIG_ENDIAN            tmp1 = 0xD800 | (c >> 10);            tmp = (unsigned char *) out;            *tmp = tmp1;            *(tmp + 1) = tmp1 >> 8;            out++;            tmp2 = 0xDC00 | (c & 0x03FF);            tmp = (unsigned char *) out;            *tmp  = tmp2;            *(tmp + 1) = tmp2 >> 8;            out++;#else /* BIG_ENDIAN */            *out++ = 0xD800 | (c >> 10);            *out++ = 0xDC00 | (c & 0x03FF);#endif /* BIG_ENDIAN */        }        else	    return(-1);    }    return(out-outstart);}/** * UTF16BEToUTF8: * @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-16 passwd as a byte array * @inlenb:  the length of @in in UTF-16 chars * * Take a block of UTF-16 ushorts in and try to convert it to an UTF-8 * block of chars out. This function assume the endian properity * is the same between the native type of this machine and the * inputed one. * * Returns the number of byte written, or -1 by lack of space, or -2 *     if the transcoding fails (for *in is not valid utf16 string) * The value of *inlen after return is the number of octets consumed *     as the return value is positive, else unpredictiable. */intUTF16BEToUTF8(unsigned char* out, int outlen,            const unsigned char* inb, int *inlenb){    unsigned char* outstart= out;    unsigned char* outend= out+outlen;    unsigned short* in = (unsigned short*) inb;    unsigned short* inend;    unsigned int c, d, inlen;#ifdef BIG_ENDIAN#else /* BIG_ENDIAN */    unsigned char *tmp;#endif /* BIG_ENDIAN */        int bits;    if ((*inlenb % 2) == 1)        (*inlenb)--;    inlen = *inlenb / 2;    inend= in + inlen;    while (in < inend) {#ifdef BIG_ENDIAN            c= *in++;#else        tmp = (unsigned char *) in;	c = *tmp++;	c = c << 8;	c = c | (unsigned int) *tmp;	in++;#endif	        if ((c & 0xFC00) == 0xD800) {    /* surrogates */	    if (in >= inend) {           /* (in > inend) shouldn't happens */	        (*inlenb) -= 2;		break;	    }#ifdef BIG_ENDIAN            d= *in++;#else            tmp = (unsigned char *) in;	    d = *tmp++;	    d = d << 8;	    d = d | (unsigned int) *tmp;	    in++;#endif	                if ((d & 0xFC00) == 0xDC00) {                c &= 0x03FF;                c <<= 10;                c |= d & 0x03FF;                c += 0x10000;            }            else 	        return(-2);        }	/* assertion: c is a single UTF-4 value */        if (out >= outend) 	    return(-1);        if      (c <    0x80) {  *out++=  c;                bits= -6; }        else if (c <   0x800) {  *out++= ((c >>  6) & 0x1F) | 0xC0;  bits=  0; }        else if (c < 0x10000) {  *out++= ((c >> 12) & 0x0F) | 0xE0;  bits=  6; }        else                  {  *out++= ((c >> 18) & 0x07) | 0xF0;  bits= 12; }         for ( ; bits >= 0; bits-= 6) {            if (out >= outend) 	        return(-1);            *out++= ((c >> bits) & 0x3F) | 0x80;        }    }    return(out-outstart);}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99精品国产| 精品人在线二区三区| 91欧美激情一区二区三区成人| 国产精品66部| 成人av第一页| av在线一区二区| 一本高清dvd不卡在线观看| 在线观看亚洲成人| 欧美网站大全在线观看| 欧美精品日韩一本| 日韩欧美一区二区视频| 欧美成人官网二区| 国产蜜臀97一区二区三区| 国产精品超碰97尤物18| 一区二区三区蜜桃网| 日韩精品每日更新| 精品在线视频一区| 粉嫩aⅴ一区二区三区四区 | 欧美日韩国产精品成人| 欧美日韩激情一区二区| 91精品国产综合久久小美女| 日韩欧美亚洲国产精品字幕久久久| www国产亚洲精品久久麻豆| 国产精品久久久久久妇女6080| 国产精品国产自产拍高清av| 一区2区3区在线看| 久久国产精品99精品国产| 国产suv精品一区二区6| 在线观看亚洲精品视频| 欧美一区二区三区免费大片| 久久精品人人做人人爽人人| 最新日韩在线视频| 日韩电影免费在线看| 国产成人精品三级麻豆| 欧洲精品一区二区| 久久在线免费观看| 亚洲欧美日韩在线播放| 秋霞午夜鲁丝一区二区老狼| 国产成人免费视频一区| 精品污污网站免费看| 精品国产一区a| 亚洲乱码国产乱码精品精小说| 婷婷一区二区三区| 成人自拍视频在线| 欧美日高清视频| 国产日产欧美一区| 亚洲va国产va欧美va观看| 国产成人午夜精品5599 | 久久亚洲精品小早川怜子| 亚洲欧美视频在线观看| 久久国内精品视频| 一本色道久久综合亚洲aⅴ蜜桃 | 欧美一二三四在线| 亚洲欧美经典视频| 国内精品自线一区二区三区视频| 91蝌蚪porny九色| 精品久久久久久综合日本欧美| 亚洲激情av在线| 国产精品18久久久久| 欧美精品亚洲二区| 亚洲黄色录像片| 国产黑丝在线一区二区三区| 欧美福利视频一区| 亚洲欧洲一区二区三区| 国产精品一区三区| 日韩欧美一二三| 亚洲国产cao| 91理论电影在线观看| 国产三区在线成人av| 免费在线观看精品| 欧美午夜精品电影| 中文字幕日韩一区| 国产v综合v亚洲欧| 久久亚区不卡日本| 麻豆精品在线看| 欧美日韩国产首页在线观看| 亚洲美女视频一区| 成人国产在线观看| 欧美激情在线一区二区三区| 久久精品国产精品亚洲综合| 777奇米成人网| 亚洲一区av在线| 色8久久精品久久久久久蜜| 国产精品国产自产拍高清av| 国产精品一区二区你懂的| 日韩美女视频一区二区在线观看| 亚洲成人久久影院| 欧美亚洲精品一区| 亚洲在线免费播放| 在线观看不卡视频| 伊人夜夜躁av伊人久久| 色综合中文字幕国产 | 亚洲精品大片www| 91亚洲男人天堂| 亚洲欧美激情一区二区| 色婷婷精品大视频在线蜜桃视频 | 国产成人精品在线看| 精品国产一区久久| 国产一区视频在线看| 久久综合av免费| 国产精品亚洲成人| 中文字幕乱码一区二区免费| 成人激情午夜影院| 一区在线观看视频| 日本电影亚洲天堂一区| 亚洲图片欧美综合| 欧美精品乱人伦久久久久久| 日本不卡一区二区| 精品少妇一区二区三区日产乱码| 久久99精品一区二区三区| 欧美精品一区二区蜜臀亚洲| 韩国成人在线视频| 国产欧美日韩中文久久| 国产精品中文字幕一区二区三区| 国产一区二区久久| 久久久久久久综合| 成人午夜免费视频| 亚洲欧美一区二区三区孕妇| 欧美日韩精品一区二区天天拍小说| 天天av天天翘天天综合网 | 婷婷综合五月天| 欧美一级艳片视频免费观看| 国产在线精品不卡| 国产精品乱人伦一区二区| 在线一区二区观看| 蜜臀av一级做a爰片久久| 久久亚洲精品国产精品紫薇| 99精品1区2区| 亚洲成人av免费| 精品国产一区久久| 99国产麻豆精品| 视频一区视频二区中文| 欧美精品一区二区不卡| 99国产精品99久久久久久| 午夜久久久久久电影| 国产夜色精品一区二区av| 99精品偷自拍| 美女免费视频一区二区| 国产精品免费视频网站| 欧美日韩国产天堂| 国产iv一区二区三区| 亚洲午夜精品一区二区三区他趣| 日韩精品资源二区在线| voyeur盗摄精品| 日本亚洲视频在线| 国产精品伦理在线| 欧美一级日韩不卡播放免费| 不卡一区二区三区四区| 免费久久精品视频| 日韩毛片视频在线看| 日韩一区二区三区视频| 99精品欧美一区二区三区综合在线| 青青草97国产精品免费观看 | 欧美精品tushy高清| 国产成人精品www牛牛影视| 亚洲成人在线免费| 国产精品你懂的| 日韩免费性生活视频播放| 91在线精品一区二区| 理论片日本一区| 亚洲一区二区三区四区中文字幕| 国产日韩v精品一区二区| 欧美乱妇20p| 91久久精品一区二区三区| 国产一区二区久久| 天堂资源在线中文精品| 亚洲少妇30p| 国产日韩av一区| 日韩精品一区二区三区蜜臀| 欧美在线免费视屏| 成人白浆超碰人人人人| 久久99精品久久久久久动态图| 亚洲午夜一区二区三区| 中文字幕视频一区二区三区久| 久久综合九色综合欧美亚洲| 欧美日韩视频在线第一区| 成人蜜臀av电影| 国产原创一区二区| 日本视频一区二区三区| 亚洲已满18点击进入久久| 日韩一区在线播放| 国产欧美视频一区二区| 精品电影一区二区三区| 欧美一级黄色大片| 欧美视频自拍偷拍| 91国内精品野花午夜精品| 99精品视频在线免费观看| 国产91丝袜在线播放0| 国产老妇另类xxxxx| 九九视频精品免费| 蜜臀va亚洲va欧美va天堂| 婷婷成人激情在线网| 亚洲午夜久久久久| 一片黄亚洲嫩模| 亚洲乱码国产乱码精品精的特点| 国产精品久久久久久久久免费丝袜| 国产三级一区二区| 国产视频一区二区三区在线观看| 久久在线观看免费| 亚洲精品一区在线观看|