text encodings
text encodings
- Subject: text encodings
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 3 Mar 2003 10:13:26 +0100
1. when I have a text in NSUnicodeStringEncoding PB (still August 2002
version) cannot handle this. Has this changed with the current version?
2. when I save the same text as NSUTF8StringEncoding PB thinks it is
NSMacOSRomanStringEncoding and all non-Ascii characters look funny.
In my own editor I have made the following observations:
3a. ok = [textStorage readFromURL: url options: nil
documentAttributes: &docAttrs];
takes NSUTF8StringEncoding as NSMacOSRomanStringEncoding (not so good!).
NSUnicodeStringEncoding is always recognized corrrectly.
3b. [ options setObject: [ NSNumber numberWithInt:
NSUTF8StringEncoding ] forKey: @"CharacterEncoding" ] ;
ok = [textStorage readFromURL: url options: options
documentAttributes: &docAttrs];
When the file is not NSUTF8StringEncoding I do not get an error
message, but the text length is zero bytes.
So my current strategy is:
load as NSUTF8StringEncoding, when zero bytes, load again without
options.
Is this the correct strategy? Or is there some other, more stable, more
efficient way to handle this?
I know that there cannot be a way to recognize encodings automatically.
And that it is a good idea to let the user handle this (same as in
TextEdit). But UTF-8 can be decided, and the probability that a text
looks like UTF-8 but is not seems rather remote.
Gerriet.
_______________________________________________
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.