-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Previous ID | SR-8115 |
Radar | None |
Original Reporter | davidw (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Attachment: Download
Environment
Ubuntu 16.04
$ 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
macOS 10.14 Beta (18A314h)
$ swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin18.0.0
Additional Detail from JIRA
Votes | 0 |
Component/s | Foundation |
Labels | Bug |
Assignee | None |
Priority | Medium |
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")
the output result on my macOS:
> name => my name
> age => 100
> data => <68656c6c 6f776f72 6c64>
the output result on Ubuntu server:
> name => my name
> age => 100
> data => 0 bytes . // <---- HERE
Problem here is the data decoded is "0 bytes"