91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4.75MB
    文件類型: .gz
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-11-07
  • 語言: 其他
  • 標(biāo)簽: libiconv??

資源簡介

This library provides an iconv() implementation, for use on systems which don't have one, or whose implementation cannot convert from/to Unicode.

資源截圖

代碼片段和文件信息

/*?Copyright?(C)?1999-2001?2003?2011?Bruno?Haible.
???This?file?is?not?part?of?the?GNU?LIBICONV?Library.
???This?file?is?put?into?the?public?domain.??*/

#include?“iconv_string.h“
#include?
#include?
#include?
#include?

#define?tmpbufsize?4096

int?iconv_string?(const?char*?tocode?const?char*?fromcode
??????????????????const?char*?start?const?char*?end
??????????????????char**?resultp?size_t*?lengthp)
{
??iconv_t?cd?=?iconv_open(tocodefromcode);
??size_t?length;
??char*?result;
??if?(cd?==?(iconv_t)(-1))?{
????if?(errno?!=?EINVAL)
??????return?-1;
????/*?Unsupported?fromcode?or?tocode.?Check?whether?the?caller?requested
???????autodetection.?*/
????if?(!strcmp(fromcode“autodetect_utf8“))?{
??????int?ret;
??????/*?Try?UTF-8?first.?There?are?very?few?ISO-8859-1?inputs?that?would
?????????be?valid?UTF-8?but?many?UTF-8?inputs?are?valid?ISO-8859-1.?*/
??????ret?=?iconv_string(tocode“UTF-8“startendresultplengthp);
??????if?(!(ret?????????return?ret;
??????ret?=?iconv_string(tocode“ISO-8859-1“startendresultplengthp);
??????return?ret;
????}
????if?(!strcmp(fromcode“autodetect_jp“))?{
??????int?ret;
??????/*?Try?7-bit?encoding?first.?If?the?input?contains?bytes?>=?0x80
?????????it?will?fail.?*/
??????ret?=?iconv_string(tocode“ISO-2022-JP-2“startendresultplengthp);
??????if?(!(ret?????????return?ret;
??????/*?Try?EUC-JP?next.?Short?SHIFT_JIS?inputs?may?come?out?wrong.?This
?????????is?unavoidable.?People?will?condemn?SHIFT_JIS.
?????????If?we?tried?SHIFT_JIS?first?then?some?short?EUC-JP?inputs?would
?????????come?out?wrong?and?people?would?condemn?EUC-JP?and?Unix?which
?????????would?not?be?good.?*/
??????ret?=?iconv_string(tocode“EUC-JP“startendresultplengthp);
??????if?(!(ret?????????return?ret;
??????/*?Finally?try?SHIFT_JIS.?*/
??????ret?=?iconv_string(tocode“SHIFT_JIS“startendresultplengthp);
??????return?ret;
????}
????if?(!strcmp(fromcode“autodetect_kr“))?{
??????int?ret;
??????/*?Try?7-bit?encoding?first.?If?the?input?contains?bytes?>=?0x80
?????????it?will?fail.?*/
??????ret?=?iconv_string(tocode“ISO-2022-KR“startendresultplengthp);
??????if?(!(ret?????????return?ret;
??????/*?Finally?try?EUC-KR.?*/
??????ret?=?iconv_string(tocode“EUC-KR“startendresultplengthp);
??????return?ret;
????}
????errno?=?EINVAL;
????return?-1;
??}
??/*?Determine?the?length?we?need.?*/
??{
????size_t?count?=?0;
????char?tmpbuf[tmpbufsize];
????const?char*?inptr?=?start;
????size_t?insize?=?end-start;
????while?(insize?>?0)?{
??????char*?outptr?=?tmpbuf;
??????size_t?outsize?=?tmpbufsize;
??????size_t?res?=?iconv(cd&inptr&insize&outptr&outsize);
??????if?(res?==?(size_t)(-1)?&&?errno?!=?E2BIG)?{
????????int?saved_errno?=?(errno?==?EINVAL???EILSEQ?:?errno);
????????iconv_close(cd);
????????errno?=?saved_errno;
????????return?-1;
??????}
??????count?+=?outptr-tmpbuf;
????}
????{
???

評(píng)論

共有 條評(píng)論