Skip to content
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

[SR-3052] [Foundation] Incorrect result of string methods while working with non latin symbols #4309

Closed
swift-ci opened this issue Oct 26, 2016 · 2 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-3052
Radar None
Original Reporter naithar (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

OS: Ubuntu 14.04.
Swift 10.25 snapshot

Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug, Linux
Assignee naithar (JIRA)
Priority Medium

md5: 06a43e5ed7d9e1fe8beff900625f8600

is duplicated by:

  • SR-1204 Truncated result of stringByAddingPercentEncodingWithAllowedCharacters

Issue Description:

Foundation methods .removingPercentEncoding and .addingPercentEncoding on Linux(Ubuntu) do not work the same as they do on MacOS, when using non latin unicode symbols.

Example code for .removingPercentEncoding:

import Foundation

let cyrillicString = "\u{0434}\u{043E}\u{043C}"
//returns "дом"
let cyrillicEscapedString = cyrillicString.removingPercentEncoding
//returns "д\u{ef}" on Linux. On MacOS returns "дом" i.e. same string which is expected

let chineseString = "\u{623F}\u{5B50}"
//returns "房子"
let chineseEscapedString = chineseString.removingPercentEncoding
//returns "\u{ef}" on Linux. For MacOS result is same as chineseString

let arabicString = "\u{0645}\u{0646}\u{0632}\u{0644}"
//returns "منزل"
let arabicEscapedString = arabicString.removingPercentEncoding
//return "من" on Linux

let randomString = "\u{00E0}\u{00E6}"
//returns "àæ"
let randomEscapedString = randomString.removingPercentEncoding
//returns "à" on Linux

let latinString = "home"
//returns "home"
let latinEscapedString = latinString.removingPercentEncoding
//returns "home"

Example code for . addingPercentEncoding:

import Foundation

let string = "\u{0434}\u{043E}\u{043C}"//returns "дом"
let escaped = string.addingPercentEncoding(withAllowedCharacters: .alphanumerics)
//returns "%D0%B4%D0", while it should return "%D0%B4%D0%BE%D0%BC"

@swift-ci
Copy link
Contributor Author

Comment by Sergey Minakov (JIRA)

After some research i found that {code:none} CFStringGetLength

@swift-ci
Copy link
Contributor Author

swift-ci commented Nov 6, 2016

Comment by Sergey Minakov (JIRA)

Fixed by #706

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant