Skip to content

Instantly share code, notes, and snippets.

@kev009
Created November 7, 2010 20:09
Show Gist options
  • Save kev009/666377 to your computer and use it in GitHub Desktop.
Save kev009/666377 to your computer and use it in GitHub Desktop.
some multibyte testing
#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