a2 / MessagePack.swift

It's like JSON, but fast and small…and Swift! – msgpack.org[Swift]
http://msgpack.org
MIT License
283 stars 60 forks source link

Unpacking of "Umlaute" doesn't work #12

Closed moogle19 closed 9 years ago

moogle19 commented 9 years ago

Characters like ä,ö,ü,é,ß doesn't unpack correctly. Packing works, but the problem with unpacking is, that these characters consist of 2 bytes instead of 1. So the unpackString method handles the character as 2 characters.

Also the determination of the string length looks wrong. The length should be "value & 0x1f" and not "value - 0xa0" if I understand it correctly.

a2 commented 9 years ago

I'll try to look at this in the next few days, but if I can't, the fastest way to fix this is, if possible, for you to submit a pull request. Thanks.

ChristianSteffens commented 9 years ago

I can reproduce this error with your testcases:

    let packed = pack(.String("Hellö wörld"))
    let unpacked = try? unpack(packed)
    XCTAssertEqual(unpacked, MessagePackValue.String("Hellö, wörld!"))

I'll take a look, since I modified the unpack routine for Strings...

a2 commented 9 years ago

Closed by #13.