NSTextView encoding fun
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