a2 / MessagePack.swift

It's like JSON, but fast and small…and Swift! – msgpack.org[Swift]

Home Page:http://msgpack.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Termination key for Pack in Swift 4

nagarajaghantasala opened this issue · comments

IOS app is packing the data to send to Linux Device by this framework.

Linux Device is unpacking by mpack library.

When I used Message pack v1.2.0 for Swift 2, pack in IOS App and unpack in Linux Device are working.

After I upgrade the Message Pack v3.0 for Swift 4, Pack is not working fine.

  1. Termination key is not generated in Pack for Swift 4 and whereas that key is generating for Swift 2.
  2. One extra byte is adding to before string value after packing the data in Swift 2. This is not happening in Swift 4.
  3. Which means if we compared Swift 2 and Swift 4 Hexa values, one Byte difference is appearing in Pack. Because of this unpacking is not happening in Device side.

Example Data :-

I used same String in Array data for Message pack v1.2.0 and v3.0

Message pack v1.2.0

32 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdef

Hexa : 91d92061 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 646566

64 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 91d94061 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 646566

128 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 

91d98061 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 646566

Message pack v3.0

32 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdef
Hexa : 916511d1 0380d103 800078aa 31313332 31323331 323391d9 61626364 65666768 696a6b6c 6d6e6f70 71727374 75767778 797a6162 63646566

64 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 91d96162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 6566

128 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 91d96162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 6566

Please provide the solution for this issue.

Thanks in Advance.

Can you provide code samples that produce the output you are seeing with MessagePack.swift v3.0?

For example, if I run the following code on master I receive this output:

let string = "abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef"
print((pack(.string(string)) as NSData).description)
<d9806162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 6566>