Skip to content

Instantly share code, notes, and snippets.

@larshelg
Created January 28, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larshelg/d6b13931c19a03e8baa9bc91cdc2eaaf to your computer and use it in GitHub Desktop.
Save larshelg/d6b13931c19a03e8baa9bc91cdc2eaaf to your computer and use it in GitHub Desktop.
tnet sting problem
Working:
Clojurescript code:
(.send socket (str "T" (tnet/dumps
{
"id" id
"code" 200
"headers" [["Content-type" "application/json"]]
"body" (.stringify (js* "JSON") "a")}))))
Generates this tnet string:
T125:2:id,36:4fe07c05-19f1-402f-aabd-2331ec06b0e5,4:code,3:200#7:headers,40:36:12:Content-type,16:application/json,]]4:body,3:"a",}
hexdump -C
00000000 54 31 32 35 3a 32 3a 69 64 2c 33 36 3a 34 66 65 |T125:2:id,36:4fe|
00000010 30 37 63 30 35 2d 31 39 66 31 2d 34 30 32 66 2d |07c05-19f1-402f-|
00000020 61 61 62 64 2d 32 33 33 31 65 63 30 36 62 30 65 |aabd-2331ec06b0e|
00000030 35 2c 34 3a 63 6f 64 65 2c 33 3a 32 30 30 23 37 |5,4:code,3:200#7|
00000040 3a 68 65 61 64 65 72 73 2c 34 30 3a 33 36 3a 31 |:headers,40:36:1|
00000050 32 3a 43 6f 6e 74 65 6e 74 2d 74 79 70 65 2c 31 |2:Content-type,1|
00000060 36 3a 61 70 70 6c 69 63 61 74 69 6f 6e 2f 6a 73 |6:application/js|
00000070 6f 6e 2c 5d 5d 34 3a 62 6f 64 79 2c 33 3a 22 61 |on,]]4:body,3:"a|
00000080 22 2c 7d 0a |",}.|
00000084
Not working:
Clojurescript code:
(.send socket (str "T" (tnet/dumps
{
"id" id
"code" 200
"headers" [["Content-type" "application/json"]]
"body" (.stringify (js* "JSON") "ø")}))))
Generates tnet string:
T125:2:id,36:4fe07c05-19f1-402f-aabd-2331ec06b0e5,4:code,3:200#7:headers,40:36:12:Content-type,16:application/json,]]4:body,3:"ø",}
hexdump -C
00000000 54 31 32 35 3a 32 3a 69 64 2c 33 36 3a 34 66 65 |T125:2:id,36:4fe|
00000010 30 37 63 30 35 2d 31 39 66 31 2d 34 30 32 66 2d |07c05-19f1-402f-|
00000020 61 61 62 64 2d 32 33 33 31 65 63 30 36 62 30 65 |aabd-2331ec06b0e|
00000030 35 2c 34 3a 63 6f 64 65 2c 33 3a 32 30 30 23 37 |5,4:code,3:200#7|
00000040 3a 68 65 61 64 65 72 73 2c 34 30 3a 33 36 3a 31 |:headers,40:36:1|
00000050 32 3a 43 6f 6e 74 65 6e 74 2d 74 79 70 65 2c 31 |2:Content-type,1|
00000060 36 3a 61 70 70 6c 69 63 61 74 69 6f 6e 2f 6a 73 |6:application/js|
00000070 6f 6e 2c 5d 5d 34 3a 62 6f 64 79 2c 33 3a 22 c3 |on,]]4:body,3:".|
00000080 b8 22 2c 7d 0a |.",}.|
00000085
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment