Xamarin.iOS - Encoding errors when deploying from Xamarin Studio on Mac
If you’re developing a Xamarin.iOS app with Visual Studio on Windows, and that app happen to display accented characters, you may find that when deploying it from Xamarin Studio on Mac the accents are replaced by a question mark, but those accents are correctly displayed when deployed from Visual Studio.
This is a known bug caused by the Storyboard Editor in Visual Studio.
Whenever you set the class name of a ViewController or control, Visual Studio generates the associated class file. But instead of creating a UTF8-encoded file as usual, Visual Studio creates a Windows-1252-encoded file.
Windows handles that encoding fine and lets you display accented characters even when you’re remotely building your app on a Mac. But when you open your project on a Mac, as Windows-1252 is not supported, it defaults to replace unknown characters by a question mark. So Xamarin Studio needs your files to be UTF8.
The solution to this problem is to ensure that all your files in your Xamarin.iOS project are UTF8-encoded.
For that, you have a lot of options like using the command terminal, softwares like Notepad++ or SublimeText, etc. Here, we will see how to change the encoding inside Visual Studio.
Open any autogenerated files by the Storyboard Editor, like a ViewController. Go to File > Advanced Save Options…
Ensure that the encoding is “Unicode (UTF-8 with signature) - Codepage 65001”. Change the value if needed.
When you click “OK”, the file will use the UTF8 encoding.
Repeat the operation on every other files.
Once done, you can open your project on Mac with Xamarin Studio and when deployed, your app will display the accented characters correctly.