Created
November 7, 2010 20:09
-
-
Save kev009/666377 to your computer and use it in GitHub Desktop.
some multibyte testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <event2/buffer.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
struct evbuffer* buf; | |
const char* msg = "abcdefghijklmn\n"; //ف ಠ_ಠ\n"; | |
char* msg2; | |
int ret, len; | |
int main(void) | |
{ | |
buf = evbuffer_new(); | |
evbuffer_expand(buf, strlen(msg)); | |
evbuffer_add(buf, msg, strlen(msg)); | |
msg2 = (char *) malloc(strlen(msg)); | |
ret = evbuffer_remove(buf, msg2, strlen(msg)); | |
len = mbstowcs(NULL,msg,0); | |
printf("string: %s bytes: %d len: %d\n", msg2, ret, len); | |
free(msg2); | |
evbuffer_free(buf); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment