Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Curly quotes in a label - how do you use them?

    var label = Ti.UI.createLabel({
        text: 'Curly quotes like this’  how do i use them',
        color: '#ff99ff',
        textAlign:'left',
        top:25,
        left:165,
        width: 150,
        height:'auto',
        font:{fontWeight:'bold',fontSize:12}
    });

Generates the following error

Error Domain=NSCocoaErrorDomain Code=261 UserInfo=0x503b970 "Operation could not be completed. (Cocoa error 261.)"

I have an array of strings that may contain many characters that will throw errors. what's the best way to escape them?

I've tried escape() and then unescaping them. Any help much appreciated.

— asked April 1st 2010 by Phi Chong
  • iphone
  • label
  • strings
  • ti.ui.createlabel
0 Comments

7 Answers

  • Ok I've figured it out, by default the editor I'm using (Coda), is creating documents with the encoding set as Western(Mac OS Roman). Changing it to unicode fixed the issue.

    Thanks for all the help.

    — answered April 2nd 2010 by Phi Chong
    permalink
    0 Comments
  • Just tossed in an array of upper ASCII characters including curly quotes with no special coding. All worked fine.

    Your example text worked as well.

    What specific characters cause problems.

    — answered April 2nd 2010 by Eldon Benz
    permalink
    0 Comments
  • What is your sdk version?

    I tested your exemple and dont have any problem.

    — answered April 2nd 2010 by Marcos Gonçalves
    permalink
    0 Comments
  • This worked for me…

    text:'La Grande \'Goule Wooden Dragon Carried in Religious Processions',
    
    — answered April 2nd 2010 by Eldon Benz
    permalink
    0 Comments
  • i'm compiling it for 3.1

    Eldon - I know how to escape a single quote. I do it for other strings in the array but the same method just doesn't work for curly ones. Is this a known bug?

    — answered April 2nd 2010 by Phi Chong
    permalink
    0 Comments
  • Try put a backslash '' before the character.

    — answered April 2nd 2010 by Peter Lum
    permalink
    0 Comments
  • After some testing it appears it's only the smart quotes - either double “ or single ’ that are causing the problems.

    Escaping them with a backslash doesn't help.

    — answered April 2nd 2010 by Phi Chong
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.