• 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
NSTextView encoding fun
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView encoding fun


  • Subject: NSTextView encoding fun
  • From: Duncan Campbell <email@hidden>
  • Date: Tue, 31 May 2005 15:26:21 +1000

Hey folks.

I'm having some problems saving the contents of an NSTextView with it escaping chars.

In the following sample code, I create a string and assign to an NSTextView:

NSString *funkyString = [[NSString alloc] initWithString:@"test% 02dtest"];

    NSTextView *myTextView = [[NSTextView alloc] init];
    [myTextView setString:funkyString];

The I save it using something like:

unsigned int encodeType = 5;
NSData *data = [[NSData alloc] initWithData:[[myTextView string] dataUsingEncoding:encodingType allowLossyConversion:YES]];
[data writeToFile:path atomically:YES];


Unfortunately, this results in the "" being converted into "-1".

If just assign the "funkString" var directly to the NSData then everything works as expected - so I am assuming there is something in NSTextView that I am not setting, such as a character encoding type or something.

Can anyone shed any light on this?

Many thx.

D.


_______________________________________________ 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: NSTextView encoding fun
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Exception raised during posting of notification
  • Next by Date: NSTableView row dragging and NSSliderCell
  • Previous by thread: Re: Setting the cursor for a link in an NSTextView
  • Next by thread: Re: NSTextView encoding fun
  • Index(es):
    • Date
    • Thread