Carl Carl - 2 months ago 8
Swift Question

How to disable string conversion in Swift?

I have a encrypted string which would be passed from the server side, now I want to test to convert it into readable language by some conventional decoding method.

but I found I totally cannot use the string:
enter image description here

The error shows:

invalid escape sequence in literal

There exists some conversions in swift string like

Is there a way for me to use pure String?

For example. in python, I can declare
a = """content"""
to represent pure String


It's the backslash (\), just before the character the up-arrow is pointing to in the error message. In a literal, this needs to be represented by a double backslash (\\).

This issue won't arise once you're no longer testing and you're doing this all with actual values; it's a feature only of literal strings.