• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Working with Unicode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Working with Unicode


  • Subject: Re: Working with Unicode
  • From: Julio Cesar Silva dos Santos <email@hidden>
  • Date: Thu, 30 Mar 2006 20:31:20 -0300

If I define the string in the header file as:
#define MY_CONSTANT "\x5cresign\x00"

Then printf("Test: %s",MY_CONSTANT) prints "Test: \resign".

OK. Fine. But this is pure C and my goal is to use this string in Objective-C so I tried the following:
NSString * myString = [NSString stringWithCString:MY_CONSTANT encoding:NSASCIIEncoding];
NSLog("Test (Obj-C): %@",myString);


prints "Test (Obj-c): \\resign";

Julio Cesar Santos
email@hidden
eMac 1GHz ComboDrive
640MB RAM
Linux User #359973


On 30/03/2006, at 19:56, John Stiles wrote:

The backslash is regular ASCII (along with all Unicode points under U+0080). You shouldn't need to do anything special to use backslashes :)
"\r" is giving you trouble because it's being converted to a return character. Similar to "\n" actually.
What exactly is displaying "\\resign"? The debugger may be tricking you. If you actually printf the string, does it look correct?



On Mar 30, 2006, at 2:39 PM, Julio Cesar Silva dos Santos wrote:

Hello,

I am trying to work with some unicode characters, especially the '\' (backslash) and I thought it would be easy but it is not. Here what I tried:
1) Created a Localizable.strings file with the characters, for example MY_CONSTANT = "\resign";


2) When I load MY_CONSTANT it looks like " esign" (the space in fact becomes a new line)

3) Changed to MY_CONSTANT = "\U005Cresign". (5C is the code for \)

4) Now it looks like "\\resign".

5) Changed to MY_CONSTANT = "\U005C\U0072esign". (72 is the code for r)

6) Now it continues to look like "\\resign".

Well, is there a way that I can have MY_CONSTANT returning "\resign"? Or do I have to take another approach?

Thanks for any help,


Julio Cesar Santos email@hidden eMac 1GHz ComboDrive 640MB RAM Linux User #359973
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Working with Unicode
      • From: Ondra Cada <email@hidden>
    • Re: Working with Unicode
      • From: John Stiles <email@hidden>
References: 
 >Working with Unicode (From: Julio Cesar Silva dos Santos <email@hidden>)
 >Re: Working with Unicode (From: John Stiles <email@hidden>)

  • Prev by Date: Re: NSTextView and ruler tab settings
  • Next by Date: Re: Working with Unicode
  • Previous by thread: Re: Working with Unicode
  • Next by thread: Re: Working with Unicode
  • Index(es):
    • Date
    • Thread