• 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: NSStringEncoding troubles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSStringEncoding troubles


  • Subject: Re: NSStringEncoding troubles
  • From: Ondra Cada <email@hidden>
  • Date: Sun, 14 Jul 2002 12:52:01 +0200

On Sunday, July 14, 2002, at 12:21 , Adrian Rutledge wrote:

...while [[NSString alloc] initWithData:bleh encoding:NSSomeStringEncoding] works, it escapes non-printing values such as ASCII 02...

So far as I can say, it does not. I guess you just falled to the "NSLog-tries-to-be-clever-when-showing-nonprintables" trap as many others did before. Just check for yourself, like with

65 /tmp> cat q.m
#import <Foundation/Foundation.h>
int main() {
id p=[NSAutoreleasePool new];
id d=[[NSData alloc] initWithBytes:"(\2)" length:3];
id s=[[NSString alloc] initWithData:d encoding:NSISOLatin2StringEncoding];
int l=[s length],i;
NSLog(@"len %d",l);
for (i=0;i<l;i++) NSLog(@"char at %d is %d",i,[s characterAtIndex:i]);
return 0;
}
66 /tmp> cc -framework Foundation q.m && ./a.out
2002-07-14 12:51:25.136 a.out[5714] len 3
2002-07-14 12:51:25.138 a.out[5714] char at 0 is 40
2002-07-14 12:51:25.138 a.out[5714] char at 1 is 2
2002-07-14 12:51:25.138 a.out[5714] char at 2 is 41
67 /tmp>

---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSStringEncoding troubles
      • From: Julien Jalon <email@hidden>
References: 
 >NSStringEncoding troubles (From: Adrian Rutledge <email@hidden>)

  • Prev by Date: Re: Sheet modal for NSTabViewItem
  • Next by Date: Re: how to hide/show/bring to front apps with Cocoa?
  • Previous by thread: Re: NSStringEncoding troubles
  • Next by thread: Re: NSStringEncoding troubles
  • Index(es):
    • Date
    • Thread