mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 09:21:00 +00:00
* Source/NSAttributedString.m
(-initWithData:options:documentAttributes:error:): Fixes for TextEdit. If no type is provided, assume plain text. If no encoding is provided, assume UTF-8 unless a UTF-16 BOM is detected. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34985 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f34db170ae
commit
01e2034c1c
2 changed files with 32 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2012-03-22 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
|
* Source/NSAttributedString.m
|
||||||
|
(-initWithData:options:documentAttributes:error:): Fixes for TextEdit.
|
||||||
|
If no type is provided, assume plain text. If no encoding is provided,
|
||||||
|
assume UTF-8 unless a UTF-16 BOM is detected.
|
||||||
|
|
||||||
2012-03-22 Eric Wasylishen <ewasylishen@gmail.com>
|
2012-03-22 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/GSThemeDrawing.m (-toolbarBorderColor): Change default to
|
* Source/GSThemeDrawing.m (-toolbarBorderColor): Change default to
|
||||||
|
|
|
@ -797,11 +797,7 @@ create_error(int code, NSString* desc)
|
||||||
}
|
}
|
||||||
if (type == nil)
|
if (type == nil)
|
||||||
{
|
{
|
||||||
if (error)
|
type = NSPlainTextDocumentType;
|
||||||
*error = create_error(0, NSLocalizedString(@"No type specified for data.",
|
|
||||||
@"Error description"));
|
|
||||||
RELEASE(self);
|
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
converter = converter_class(type, NO);
|
converter = converter_class(type, NO);
|
||||||
|
@ -829,6 +825,30 @@ create_error(int code, NSString* desc)
|
||||||
NSDictionary *defaultAttrs = [options objectForKey: @"DefaultAttributes"];
|
NSDictionary *defaultAttrs = [options objectForKey: @"DefaultAttributes"];
|
||||||
NSString *str;
|
NSString *str;
|
||||||
|
|
||||||
|
if (encoding == GSUndefinedEncoding)
|
||||||
|
{
|
||||||
|
encoding = NSUTF8StringEncoding;
|
||||||
|
|
||||||
|
if ([data length] >= 2)
|
||||||
|
{
|
||||||
|
static const unichar byteOrderMark = 0xFEFF;
|
||||||
|
static const unichar byteOrderMarkSwapped = 0xFFFE;
|
||||||
|
const unichar firstChar = ((const unichar *)[data bytes])[0];
|
||||||
|
if (firstChar == byteOrderMark
|
||||||
|
|| firstChar == byteOrderMarkSwapped)
|
||||||
|
{
|
||||||
|
encoding = NSUnicodeStringEncoding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dict != NULL)
|
||||||
|
{
|
||||||
|
*dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
NSPlainTextDocumentType, NSDocumentTypeDocumentAttribute,
|
||||||
|
nil];
|
||||||
|
}
|
||||||
|
|
||||||
str = [[NSString alloc] initWithData: data
|
str = [[NSString alloc] initWithData: data
|
||||||
encoding: encoding];
|
encoding: encoding];
|
||||||
self = [self initWithString: str
|
self = [self initWithString: str
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue