¹ØÓÚ linux ÖÐ iconv() º¯Êý µÄÎÊÌâ
×î½üÔÚдspider ÐèÒªÒª½â¾ö ±àÂëת»» ÎÊÌâ Óõ½ iconv() º¯Êý
µ«Ò²²»ÖªµÀ ÄÄÀïÓÐÎÊÌâ ÀÏÊÇÕû²»³öÀ´ ÄÄλ´óÏÀ °ï°ïæ
´úÂë ÈçÏ£º£¨Í·Îļþû¸´ÖÆ£©
//CodeConvert.cpp
#include "CodeConvert.h"
#include "stdlib.h"
#include <string.h>
#include <errno.h>
CCodeConv::CCodeConv(const char *from_charset,const char *to_charset)
{
cd=iconv_open(to_charset,from_charset);
if( cd== (iconv_t) -1 )
{
cout < <"cannot open iconv discripter!" < <endl;
iconv_close(cd);
exit(0);
}
}
CCodeConv::~CCodeConv()
{
iconv_close(cd);
}
bool CCodeConv::Convert(char *inbuf,long inlen,char *outbuf,long outlen)
{
char **pin=&inbuf;
char **pout=&outbuf;
memset(outbuf,0,outlen);
if( -1==iconv(cd,pin,(size_t *)&inlen,pout,(size_t *)&outlen) )
{
cout < <"have error in iconv()!" < <endl;
cout < <errno < <" " < <strerror(errno) < <endl;
return false;
}
return true;
}
#include "CodeConvert.h"
#include <string.h>
int main()
{
char *in="Íõ";
Ïà¹ØÎÊ´ð£º
д³öÍê³ÉÒÔϹ¦ÄܵÄLinuxÃüÁî:
1) ÔÚµ±Ç°Ä¿Â¼¼°Æä×ÓĿ¼ËùÓеÄ.cppÎļþÖвéÕÒ×Ö·û´®"example", ²»Çø·Ö´óСд;
2) ʹÓÃsedÃüÁî, ½«ÎļþxyzÖеĵ¥´ÊAAAÈ«²¿Ì滻ΪBBB;
3) ÓÃÒ»ÌõÃüÁî´´½¨aa bb ccÈ ......
ÎÒÒªÐÞ¸ÄÒ»¸öLinux³ÌÐòÖеÄÒ»¸ö×Ö·û´®£¬Ä¿µÄ´®±ÈÔÀ´µÄ³¤£¬ËùÒÔÖ±½ÓÌæ»»³ÌÐòÎÞ·¨ÔËÐУ¬ÒªÔõô°ì²ÅÄÜʹ³ÌÐòÕý³£ÔËÐУ¿
²»Ã÷°×ÄãÒª¸Éʲô ¸Äʲô³ÌÐò£¿
Ò»¸öÊÖ»úÉϵÄÄ£ÄâÆ÷£¬±¾À´ÊÇÔÚ/mmc/mmca1Ï´´½¨RomsÎļþ¼Ð£¬ ......
ÎÒÏÖÔÚÓõÄÊÇdpch ½øÐÐÅäÖõÄ
Perl code:
abc ~ # ifconfig
eth0 Link encap:Ethernet HWaddr 00:1e:ec:c1:94:75
inet addr:10.2.0.144 Bcast:10.2.1.255 Mask:255.255.254.0
......
chmodÖеÄmode_t²ÎÊý£¬ÈçºÎ¶¯Ì¬µÄ´«ÈëÖµ£¬ÀýÈç ÎÒÒª´«Èë0777»ò0444£¬µ«ÎÒÊäÈëµÄÊÇ×Ö·û´® Ôõôת»¯Îª8½øÖÆ
ÿ¸öģʽ¾ùÔ¤¶¨ÒåÓк꣬ÓÖÒòΪÆäʵ¿ÉÑ¡·ÖÖ§ÓÐÏÞ£¬Äã¿ÉÒÔÅжÏÊäÈëµÃ×Ö·û´®£¬Ê¹ÓÃswicthÖ®ÀàµÃ°ì·¨£¬¸øÒ»ÁÙʱ ......