When I try to use MonoDevelop to make my scripts, I have a strange behaviour with “foreign” characters like those of french or chinese languages.
If I make a simple script with:
string s = "Je suis une phrase en français.";
string chinese = "我是一个中国人的一句。";
string arabic = "أنا العبارة العربية."; // Don't bother about RTL stuff, it is just a test
Debug.Log (s);
Debug.Log (hindi);
Debug.Log (arabic);
I am getting this in console (or GUI):
Even if I set UTF-8 in the save options of the file, it doesn’t change anything. But if I set a character encoding that cannot handle the characters from the script, for example the Western ISO one, when saving, MonoDevelop will ask me if I want to resave using Unicode. If I say yes, then that’s what I get in console:
So my first question is : why should I choose an incorrect encoding in order to have the correct encoding in the end?
My second question is about the UTF-16 encoding: whenever I try to use this, I have a parse error in the editor (Assets/Unicode2.cs(1,5): error CS8025: Parsing error). Does Unity supports UTF-16 or not?
At the moment, I use Visual C# which is less buggy about this problem.
I done experiment with your code. What i does i put all you string variables in onescript made with notepad++ and save As UTF-8. I changed all your string variables to public static and access all variables from another script and now i can see all variable as it in console window when i try to print.
if i open the script which i made in notepad++ in monodevelop, then its show again wrong character in console window. Show never open that script with monodevelop.
Where can I set the BOM in MonoDevelop? I can only see the UTF-8.
I’m on Windows and I would like to stay on C# language because I prefer it to JS. So is it better to develop on Mac?
I know this is a good solution for character encoding problems (to use Notepad++). But at the moment, I am making an editor script with a lot of “plain” strings (not in variables). As those strings helps me to locate myself in the script, I am not willing to use that method.
But what I have found is that when I make a special manipulation in MonoDevelop, the scripts in MonoDevelop works perfectly in UTF-8. Like it was a hidden saving functionality…
The secret manipulation as described above:
File > Save As…
Character Coding: “Western ISO-8859-15” or whatever coding which does not support your strings characters
Click “Save” button
Click “Overwrite File” button
Click “Save as Unicode” button
Your file is correctly saved as UTF-8 for Unity! Now, even if you save the file again with the SaveCtrl+S command, the script will correctly show the good characters in the editor.
If at the last step, MonoDevelop was not saving the file correctly for Unity, I would just say: “MonoDevelop does not support UTF-8 for Unity, end of story”. But here, MonoDevelop can actually save in Unity’s UTF-8, and what I have to say is that the saving feature is not consistent…
So it seems that MonoDevelop is just bugged on that point. Is it not?
I asked a similar question recently. Apparently you should use UTF-16 for C#. I found I had to change the format of all the scripts in my project to get it to work.
I use Unitron instead of MonoDevelop. I set Unitron to open in UTF-8 (I use JS instead of C#) using Preferences. I assume similar principles work in MonoDevelop / C#.
My problem seems very similar to this .
I have tried the various remedies to save with notePad++, MonoDevelp with no effect. (Code saved with UTF-16 in MonoDevelop seems not readable in Unity.)
I am using C# and MonoDevelop and have problems with lines like:
myTextMesh.text = "Ñ"; // a one letter string of a Capital N with a tilde
If I just copy and paste Ñ (from part of a script in MonoDevelop) in the text field of myTextMesh using Unity
Editor it comes right out on my mesh.So I have imported my font correctly, I think.
I am adopting my word game to Spanish and I really need to be able to handle this (and similar font problems)
in C#, not cut-and-paste.
Below three completely self contained lines of code below, copied and pasted from MonoDevelop and the
console output.
what do I need to do to make that first line come out with Ñ and not Ñ?
Debug.Log("Well OK so Ñ looks like what when printed??");
char daString ='\u00D1';
Debug.Log(" Another thing to try is : "+daString.ToString());
…and in the console, in detail, it comes out like this: