CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
795 stars 107 forks source link

Value with copyright symbol © has its preceding whitespace trimmed off even `trimValueWhitespaces` is set to false #141

Closed DJBen closed 4 years ago

DJBen commented 4 years ago

See test case added in my commit that verifies this issue https://github.com/MaxDesiatov/XMLCoder/commit/82d9bac8a39926960efdd9a93d54af3ead0d2121

Regardless of nested or not, parsing something like <t>Copyright © 2019 Company, Inc.</t> gets me "Copyright© 2019 Company, Inc" with the preceding whitespace before © trimmed off.

I look for the codebase and found the only place involving trimmingCharacters is in XMLStackParser:114. But later I found that the Foundation method to trim whitespace is not the culprit either.

XCTAssertEqual("Copyright © 2019 Company, Inc.".trimmingCharacters(in: .whitespacesAndNewlines), "Copyright © 2019 Company, Inc.") => true

So I am confused. Any pointer is appreciated.

MaxDesiatov commented 4 years ago

In my testing setting trimValueWhitespaces to false on a decoder in #147 fixes the issue. I agree this is unexpected behaviour, but unfortunately at this point our 0.9 release is overdue. I'll consider this a duplicate of #129 and will potentially schedule it for 0.10 timeframe. In the meantime setting trimValueWhitespaces to false is an acceptable workaround, I hope. 🤞

DJBen commented 4 years ago

Okay thanks.