Created
December 28, 2015 16:45
-
-
Save mialinx/eaaa22c50de73c257770 to your computer and use it in GitHub Desktop.
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
[nuf@nuftop tmp]$ cat 1.go | |
package main | |
import ( | |
"fmt" | |
"gopkg.in/vmihailenco/msgpack.v2" | |
) | |
func main() { | |
b, _ := msgpack.Marshal(int(128)) | |
fmt.Printf("%02x\n", b) | |
} | |
[nuf@nuftop tmp]$ go run 1.go | |
d10080 | |
[nuf@nuftop tmp]$ cat 1.c | |
#include <msgpack.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
msgpack_sbuffer * sbuf = msgpack_sbuffer_new(); | |
msgpack_packer *pk = msgpack_packer_new(sbuf, msgpack_sbuffer_write); | |
msgpack_pack_unsigned_int(pk, 128); | |
int i; | |
for (i = 0; i < sbuf->size; i++) { | |
printf("%x", (unsigned char) sbuf->data[i]); | |
} | |
printf("\n"); | |
return 0; | |
} | |
[nuf@nuftop tmp]$ ./a.out | |
cc80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment