Skip to content

[4.2] SR-7455: Allow NUL in Strings to match Darwin #1890

New issue

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

Merged
merged 3 commits into from
Feb 8, 2019

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Feb 8, 2019

  • String._conditionallyBridgeFromObjectiveC:
    Use String(decoding:as: UTF8.self) instead of String(cString:) to allow NULs in the decoded string.

  • Update tests which use buffers with trailing zeros to create strings,
    making the tests work correctly against Darwin's native Foundation.

(cherry picked from commit 860956a)

  • If CFStringGetLength() returns 0 just create an empty string ("").

  • Try CFStringGetCharactersPtr() before CFStringGetCharacters()
    to avoid allocating a buffer.

(cherry picked from commit 666c8c4)

  • Add tests for multibyte UTF-8/ UTF-16.

(cherry picked from commit 8422c1a)

- String._conditionallyBridgeFromObjectiveC:
  Use String(decoding:as: UTF8.self) instead of String(cString:) to
  allow NULs in the decoded string.

- Update tests which use buffers with trailing zeros to create strings,
  making the tests work correctly against Darwin's native Foundation.

(cherry picked from commit 860956a)
- If CFStringGetLength() returns 0 just create an empty string ("").

- Try CFStringGetCharactersPtr() before CFStringGetCharacters()
  to avoid allocating a buffer.

(cherry picked from commit 666c8c4)
- Add tests for multibyte UTF-8/ UTF-16.

(cherry picked from commit 8422c1a)
@spevans
Copy link
Contributor Author

spevans commented Feb 8, 2019

String bridging fix.

@spevans
Copy link
Contributor Author

spevans commented Feb 8, 2019

@swift-ci test 4.2

@kevints
Copy link
Contributor

kevints commented Feb 8, 2019

@swift-ci test and merge

@swift-ci swift-ci merged commit 5acae43 into swiftlang:swift-4.2-branch Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants