Author Topic: Using accented characters, for example "è", in a label.  (Read 5991 times)

grantmoore3d

  • Guest
Using accented characters, for example "è", in a label.
« on: September 26, 2012, 07:26:36 PM »
I'm having trouble using characters like, è, in a label. The problems isn't NGUI, but the way that character is being stored. The line of code is...

  1. mainLabel.GetComponent<UILabel>().text = "Sysètme Circulatoire";

...but when I log what is being stored (and displayed) it comes out as...

  1. Sysètme Circulatoire

I also tried storing that as a string first, with the same results. It seems the è in the quotes is not being interpreted correctly. Is there some trick I'm missing for these special characters in C#?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Using accented characters, for example "è", in a label.
« Reply #1 on: September 26, 2012, 08:25:27 PM »
The file it's coming from must be saved as UTF-8, and even then I'm not sure if it works when set from code. Try putting it in a text file and loading it from there (use Localization).

grantmoore3d

  • Guest
Re: Using accented characters, for example "è", in a label.
« Reply #2 on: September 28, 2012, 02:52:34 AM »
Alright, I'll give that a try. I do have to eventually get text reading from a text file anyways, so it might as well be now.

Philipp_S

  • Guest
Re: Using accented characters, for example "è", in a label.
« Reply #3 on: January 22, 2013, 08:34:05 AM »
We've had the same problem (Umlauts showing up as "??"), and since loading from a text file wasn't an option, I've tried a few things and was able to get unicode characters assigned from code to work. The trick seems to be to save the .cs file containing the code using UTF-16 encoding. You can do so by choosing "Save as" in Monodevelop. Hope that helps someone.