You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MacOS High Sierra Version 10.13.3
running Xcode 9.3 and swift 4.1
Ubuntu 14.04
Running swift 4.1
(Same results running: trunk Development master)
Additional Detail from JIRA
Votes
1
Component/s
Foundation
Labels
Bug, Linux
Assignee
None
Priority
Medium
md5: c5658bb6ac71236289a1eb0d264f1e62
Issue Description:
There is a difference in behavior with how the null character is handled when converting between Data and UTF8 between Linux and iOS.
When using the following code snippet:
importFoundationvartestString = "\u{00} This is a test string"varsomedata = testString.data(using: String.Encoding.utf8)!
print(somedata)
iflettext = String(data: somedata, encoding: .utf8) {
print(text.count)
print(text)
}
somedata will be "23 bytes"
On iOS:
text.count will be 23
text will be " This is a test string"
On linux:
text.count will be 0
text will be ""
So in the conversion from data to utf8 String, Linux will stop at the null character and ignore anything after it whereas iOS will convert everything including and after the null character.
The text was updated successfully, but these errors were encountered:
Environment
Tested on:
MacOS High Sierra Version 10.13.3
running Xcode 9.3 and swift 4.1
Ubuntu 14.04
Running swift 4.1
(Same results running: trunk Development master)
Additional Detail from JIRA
md5: c5658bb6ac71236289a1eb0d264f1e62
Issue Description:
There is a difference in behavior with how the null character is handled when converting between Data and UTF8 between Linux and iOS.
When using the following code snippet:
somedata will be "23 bytes"
On iOS:
text.count will be 23
text will be " This is a test string"
On linux:
text.count will be 0
text will be ""
So in the conversion from data to utf8 String, Linux will stop at the null character and ignore anything after it whereas iOS will convert everything including and after the null character.
The text was updated successfully, but these errors were encountered: