Unicode Characters

  • Hi,

    Here are a few lines of Obj-C that are, alas, not working.

    {
    NSString *s;
    s=@"@";  //for those who won't read Unicode characters,  this is
    supposed to be the russian letter "you"
    [texteRU setString:s];
    }

    Where am I mistaking ? I changed my PB prefs to Unicode UTF-8 encoding
    and I get the Unicode letters from my keyboard by switching it to
    "Unicode Entry" (from the International SysPrefs). I regularly do this
    without any problem with TextEdit or Mail and I get the appropriate
    character in PB's text editor. But when I launch the app, the rusian
    character turns into a "-e" or any 8bit-ASCII string

    Why doesn't it work ?

    Mactov
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • On 18/3/03 7:23 pm, Mactov <mactov...> wrote:

    > Hi,
    >
    > Here are a few lines of Obj-C that are, alas, not working.
    >
    > {
    > NSString *s;
    > s=@"@";    //for those who won't read Unicode characters,  this is
    > supposed to be the russian letter "you"
    > [texteRU setString:s];
    > }
    >
    > Where am I mistaking ? I changed my PB prefs to Unicode UTF-8 encoding
    > and I get the Unicode letters from my keyboard by switching it to
    > "Unicode Entry" (from the International SysPrefs). I regularly do this
    > without any problem with TextEdit or Mail and I get the appropriate
    > character in PB's text editor. But when I launch the app, the rusian
    > character turns into a "-e" or any 8bit-ASCII string
    >
    > Why doesn't it work ?
    >
    > Mactov

    The @"..." notation only permits 7-bit ASCII characters inside the string.
    You need to think of another way of embedding Unicode text into your program
    - there are a couple!

    Cheers,

    Chris
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • I have seen this method to insert a single Unicode character; and it
    may not be fun to use if you have longer things (like words) to write.
    [field setStringValue:[NSString stringWithFormat:@"%C",0x266B]];

    Where 0x266B is the address of the unicode character (in this case two
    notes).
    You can find all of them at http://www.unicode.org/charts/

    There is also the NSString method
    + (id)stringWithUTF8String:(const char *)bytes
    of which I have no experience, but you should try it out.

    Ulrik

    tisdagen den 18 mars 2003 kl 20.40 skrev Chris Ridd:

    > On 18/3/03 7:23 pm, Mactov <mactov...> wrote:
    >
    >> Hi,
    >>
    >> Here are a few lines of Obj-C that are, alas, not working.
    >>
    >> {
    >> NSString *s;
    >> s=@"@";    //for those who won't read Unicode characters,  this is
    >> supposed to be the russian letter "you"
    >> [texteRU setString:s];
    >> }
    >>
    >> Where am I mistaking ? I changed my PB prefs to Unicode UTF-8 encoding
    >> and I get the Unicode letters from my keyboard by switching it to
    >> "Unicode Entry" (from the International SysPrefs). I regularly do this
    >> without any problem with TextEdit or Mail and I get the appropriate
    >> character in PB's text editor. But when I launch the app, the rusian
    >> character turns into a "-e" or any 8bit-ASCII string
    >>
    >> Why doesn't it work ?
    >>
    >> Mactov
    >
    > The @"..." notation only permits 7-bit ASCII characters inside the
    > string.
    > You need to think of another way of embedding Unicode text into your
    > program
    > - there are a couple!
    >
    > Cheers,
    >
    > Chris
    > _______________________________________________
    > cocoa-dev mailing list | <cocoa-dev...>
    > Help/Unsubscribe/Archives:
    > http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    > Do not post admin requests to the list. They will be ignored.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • On Tuesday, Mar 18, 2003, at 14:23 US/Eastern, Mactov wrote:

    > Hi,
    >
    > Here are a few lines of Obj-C that are, alas, not working.
    >
    > {
    > NSString *s;
    > s=@"@";     //for those who won't read Unicode characters,  this is
    > supposed to be the russian letter "you"
    > [texteRU setString:s];
    > }
    >
    > Where am I mistaking ? I changed my PB prefs to Unicode UTF-8 encoding
    > and I get the Unicode letters from my keyboard by switching it to
    > "Unicode Entry" (from the International SysPrefs). I regularly do this
    > without any problem with TextEdit or Mail and I get the appropriate
    > character in PB's text editor. But when I launch the app, the rusian
    > character turns into a "-e" or any 8bit-ASCII string

    If, as you say, your source code files are encoded as UTF-8, then try
    this:

    NSString    *s;
    s    = [NSString stringWithUTF8String: "<put your string here>"];
    [texteRU setString: s];

    >
    > Why doesn't it work ?

    Because the @"" noitation only works with 7-bit ASCII characters

    --
    http://homepage.mac.com/clarkcox3/
    <clarkcox3...>
    Clark S. Cox, III
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • >> Hi,
    >>
    >> Here are a few lines of Obj-C that are, alas, not working.
    >>
    >> {
    >> NSString *s;
    >> s=@"@";    //for those who won't read Unicode characters,  this is
    >> supposed to be the russian letter "you"
    >> [texteRU setString:s];
    >> }
    >>
    >> Where am I mistaking ? I changed my PB prefs to Unicode UTF-8 encoding
    >> and I get the Unicode letters from my keyboard by switching it to
    >> "Unicode Entry" (from the International SysPrefs). I regularly do this
    >> without any problem with TextEdit or Mail and I get the appropriate
    >> character in PB's text editor. But when I launch the app, the rusian
    >> character turns into a "-e" or any 8bit-ASCII string
    >>
    >> Why doesn't it work ?
    >>
    >> Mactov
    >
    > The @"..." notation only permits 7-bit ASCII characters inside the
    > string.
    > You need to think of another way of embedding Unicode text into your
    > program
    > - there are a couple!
    >
    I was given the (one possible ?) answer by Clark S. Cox III and I now
    use     s = [NSString stringWithUTF8String: "<put your string here>"];
    and it works as I wanted

    --

    mAKTOW
    <mactov...>
    http://www.projectomega.org/fr/
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month march 2003 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today