Search code examples
xcodeencodingxcode11

What is the `text encoding` of source swift files on Xcode


I was trying to copy-paste a UTF-8 string with Japanese characters and saved it assigned to a variable on swift. When I was trying to parse that variable with json string I see encoding issues in the exception.

Anyways I solved it by putting the content in an external file and loading it from bundle of course the encoding was same as before which is .utf8 and it worked.

I later read from the File Inspector that Swift file where the Text Encoding is mentioned as No Explicit Encoding.

Can someone point to documentation which says what is the Text Encoding by default when any source files are added to Xcode 11 onwards. Thanks


Solution

  • It is in Xcode Preferences on Text Editing pane. Please look my attached.

    enter image description here