我想在C中将unicode中的字符串转换为ascii.我的问题是,我试图在数据包的tcp有效负载中找到数据包的字符串POST,但我找不到它,因为它可能是utf-8编码的.我知道ascii有更多unicode字符,但我认为问题是......我已经为C#找到了一些东西,但是你知道C是否存在某些东西?
我正在使用pcap库,但我不知道为什么我总是得到这个输出:
大小的新数据包:udata = 8 hdr = 8 pkt = 8
这是代码:
void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt)
{
DEBUG("DANY new packet with size: udata= %d hdr=%d pkt=%d", (int) sizeof(udata),(int) sizeof(hdr),(int) sizeof(pkt) );
...
stuff
}
Run Code Online (Sandbox Code Playgroud)
在我使用的另一个文件中:
status = pcap_loop (pcap_obj,
-1 /* How many packets it should sniff for before returning (a negative value
means it should sniff until an error occurs (loop forever) ) */,
handle_pcap /* Callback that will be called*/,
NULL /* Arguments …Run Code Online (Sandbox Code Playgroud)