Results 1 to 4 of 4

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: UITextLabel, call 'setText' with non-ASCII Chars

  1. #1
    Default UITextLabel, call 'setText' with non-ASCII Chars
    Hi

    I'm trying to implement a UITextLabel object
    i need to write [MyUITextLabelObj setText: @"אבג"];

    This string MUST contain non-ASCII Characters like the ones i wrote above...
    when i compile i get a warning
    warning: non-ASCII character in CFString literal
    and i cant see the characters on screen (i see weird characters instead).

    I've tried to do something like this:
    NSString *myStr = [[NSString alloc] initWithUTF8String: "@"אבג"];
    [MyUITextLabelObj setText: myStr];

    but this also doesnt work and display nothing on the label

    How can i achieve this functionality ?
    any idea's about what to try next ?

    Thanks !

  2. #2
    Your string passed to initWithUTF8String should not have the "@ or the @ - it expects a regular C-string literal.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

  3. #3
    First, It's nice to see Hebrew
    Second, I had the same problem and didn't find a good solution. To use special characters you can do smth like:

    unichar uc[1] = {0x2190}; //backspace sign

    [MyUITextLabelObj setText: [NSString stringWithCharacters:uc length:1]];

    The more convenient way is to use .plist files (just save them as utf-8), and load your data from there (then it works OK).

  4. #4
    Hi vladimir

    yes, its Hebrew

    I found a way to achieve that.
    i write:
    [myUITextLabelObj setText: [NSString stringWithUTF8String: "שלום"]];

    and i make sure to save the file in UTF-8 (i use Notepad++ so in the Format menu i choose "Encode UTF-8 without BOM")
    and it works.

    FYI

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •