Browse Source

show byte as dec as in erlang (not in hex)

221V 1 day ago
parent
commit
10c70af574
2 changed files with 5 additions and 4 deletions
  1. 2 1
      vtest/source/bert.d
  2. 3 3
      vtest/source/ws_bert_login.d

+ 2 - 1
vtest/source/bert.d

@@ -105,7 +105,8 @@ struct BertValue{
         result.put("<<");
         foreach(i, b; binaryValue){
           if(i > 0){ result.put(","); }
-          result.put(format("%02X", b));
+          //result.put(format("%02X", b)); // string bytes in hex = <<"blabla">> = <<62,6C,61,62,6C,61>>
+          result.put(to!string(b)); // string bytes in dec (like in erlang) = <<"blabla">> = <<98,108,97,98,108,97>>
         }
         result.put(">>");
         return result.data;

+ 3 - 3
vtest/source/ws_bert_login.d

@@ -57,17 +57,17 @@ void msg_match(BertValue decoded, WebSocket sock){
       } // else do nothing
       
       if(auto str1 = cast(string)decoded1[1].binaryValue){
-        writeln("str1 = ", str1, " ", typeof(str1).stringof); // ws.send(enc(tuple( number(1), bin('blabla'), number(777) ))); // Decoded: {1, <<62,6C,61,62,6C,61>>, 777} // str1 = blabla string
+        writeln("str1 = ", str1, " ", typeof(str1).stringof); // ws.send(enc(tuple( number(1), bin('blabla'), number(777) ))); // Decoded: {1, <<98,108,97,98,108,97>>, 777} // str1 = blabla string
         sock.send("{console.log('" ~ str1 ~ " la-la-la" ~ "')}"); // got 'blabla la-la-la' in browser console
         
       } // else do nothing
       
       if(decoded1[2].type_ == BertType.List){
-        auto list1 = decoded1[2].listValue; // ws.send(enc(tuple( number(1), bin('blabla'), list( number(1), number(2), number(3) ) ))); // Decoded: {1, <<62,6C,61,62,6C,61>>, [1, 2, 3]}
+        auto list1 = decoded1[2].listValue; // ws.send(enc(tuple( number(1), bin('blabla'), list( number(1), number(2), number(3) ) ))); // Decoded: {1, <<98,108,97,98,108,97>>, [1, 2, 3]}
         if(list1.length == 3){
           
           if(auto num31 = cast(uint32)list1[0].intValue){
-            writeln("num31 = ", num31, " ", typeof(num31).stringof); // ws.send(enc(tuple( number(1), bin('9'), list( number(1), number(2), number(3) ) ))); // Decoded: {1, <<39>>, [1, 2, 3]} // num31 = 1 int
+            writeln("num31 = ", num31, " ", typeof(num31).stringof); // ws.send(enc(tuple( number(1), bin('9'), list( number(1), number(2), number(3) ) ))); // Decoded: {1, <<57>>, [1, 2, 3]} // num31 = 1 int
             sock.send("{console.log(" ~ to!string(num31 + 77) ~ ")}"); // got 78 in browser console
           } // else do nothing