We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment: Download
$ cat /etc/*release
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS" NAME="Ubuntu" VERSION="16.04.4 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.4 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial
$ swift --version
Swift version 4.1.2 (swift-4.1.2-RELEASE) Target: x86_64-unknown-linux-gnu
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3) Target: x86_64-apple-darwin18.0.0
md5: 997ac8a236abe1350659cdaa41a1c63f
Issue Description:
///// main.swift import Foundation let name: String = "my name" let age: UInt32 = 100 let myData: Data = "helloworld".data(using: .utf8)! let properties: [String: Any] = [ "name": name, "age": age, "data": myData ] do { // pack let packedData = try PropertyListSerialization.data(fromPropertyList: properties, format: .binary, options: 0) // unpack let unpackedProps = try PropertyListSerialization.propertyList(from: packedData, options: [], format: nil) guard let newProperties = unpackedProps as? [String: Any] else \{ fatalError("error: not a dictionary type") } for item in newProperties \{ print("# \(item.key) => \(item.value)") } } catch \{ print("serialize message error: \(error)") exit(0) } print("all done")
> name => my name > age => 100 > data => <68656c6c 6f776f72 6c64>
> name => my name > age => 100 > data => 0 bytes . // <---- HERE
Problem here is the data decoded is "0 bytes"
The text was updated successfully, but these errors were encountered:
cc @millenomi
Sorry, something went wrong.
This is now fixed in 4.2.4 by #1958
import Foundation let name: String = "my name" let age: UInt32 = 100 let myData: Data = "helloworld".data(using: .utf8)! let properties: [String: Any] = [ "name": name, "age": age, "data": myData ] do { // pack let packedData = try PropertyListSerialization.data(fromPropertyList: properties, format: .binary, options: 0) // unpack let unpackedProps = try PropertyListSerialization.propertyList(from: packedData, options: [], format: nil) guard let newProperties = unpackedProps as? [String: Any] else { fatalError("error: not a dictionary type") } for item in newProperties { print("# \(item.key) => \(item.value)") } print("name:", newProperties["name"] as! String) print("age:", newProperties["age"] as! UInt32) print("data:", String(data: newProperties["data"] as! Data, encoding: .utf8)!) } catch { print("serialize message error: \(error)") exit(0) } $ ~/swift-4.2.4-RELEASE-ubuntu18.04/usr/bin/swift sr-8115.swift # age => 100 # name => my name # data => 10 bytes name: my name age: 100 data: helloworld
No branches or pull requests
Attachment: Download
Environment
Ubuntu 16.04
macOS 10.14 Beta (18A314h)
Additional Detail from JIRA
md5: 997ac8a236abe1350659cdaa41a1c63f
Issue Description:
the output result on my macOS:
the output result on Ubuntu server:
Problem here is the data decoded is "0 bytes"
The text was updated successfully, but these errors were encountered: