Author Topic: Apostrophes in labels  (Read 5436 times)

athos

  • Guest
Apostrophes in labels
« on: November 27, 2012, 11:12:03 PM »
Anyone having trouble getting an apostrophe to show up inside a label? It's not showing up for me, so I tried escaping with a backslash, but that just gave me a backslash. :-)

athos

  • Guest
Re: Apostrophes in labels
« Reply #1 on: November 27, 2012, 11:18:52 PM »
I updated UILabel.ProcessText as follows and now I can at least get an apostrophe to render by escaping it.

mProcessedText = mText.Replace("\\n", "\n").Replace("\\'", "'");

Would this be useful to include in a future update?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Apostrophes in labels
« Reply #2 on: November 28, 2012, 02:06:08 AM »
Eh? This change makes no sense. An apostrophe is not a special character, and it works perfectly fine as-is. It's only a special character if you are doing this:
  1. char someChar = '\'';

athos

  • Guest
Re: Apostrophes in labels
« Reply #3 on: November 28, 2012, 02:20:48 AM »
I'm glad it works for you, but it doesn't work for me. I can type this in for the text of a label:

This user's test.

And it renders as:

This users test.

I added the escape sequence to work around the issue.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Apostrophes in labels
« Reply #4 on: November 28, 2012, 02:23:40 AM »
Look at the menu example that comes with NGUI. The text there reads:

"Since this is merely an example of NGUI's functionality..."

Note the apostrophe. Shows up fine.

athos

  • Guest
Re: Apostrophes in labels
« Reply #5 on: November 28, 2012, 02:48:31 AM »
Very interesting. That scene just rendered correctly for me too, so I tested the label in my test scene again and it still refused to render the apostrophe without the code change. I just grabbed the latest from the asset store as I was a couple releases behind, rebuilt, and now both are rendering fine. I don't what was going on there, but glad it's working now. Thanks!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Apostrophes in labels
« Reply #6 on: November 28, 2012, 01:36:18 PM »
Sounds like the apostrophe was missing from your font, then it just doesn't render.

athos

  • Guest
Re: Apostrophes in labels
« Reply #7 on: November 28, 2012, 01:55:21 PM »
Thanks, I thought that too at first. But, I did check that, and it rendered when I did the escaping trick. I've had some odd problems like this in the past with Unity's build folder getting out of whack, so pulling down the latest and recompiling those scripts must have put things back to a good state.