+2011-01-29 Jan Djärv <jan.h.d@swipnet.se>
+
+ * nsselect.m (ns_string_from_pasteboard): Get length of string
+ and use make_string instead of build_string (Bug#7934).
+ (ns_string_to_pasteboard_internal): Use initWithBytesNoCopy
+ instead of stringWithUTF8String (Bug#7934).
+
2011-01-29 Anders Lindgren <andlind@gmail.com> (tiny change)
* nsfont.m (nsfont_open): Ensure that fonts with inexact
CHECK_STRING (str);
utfStr = SDATA (str);
- nsStr = [NSString stringWithUTF8String: utfStr];
-
+ nsStr = [[NSString alloc] initWithBytesNoCopy: utfStr
+ length: SBYTES (str)
+ encoding: NSUTF8StringEncoding
+ freeWhenDone: NO];
if (gtype == nil)
{
[pb declareTypes: ns_send_types owner: nil];
{
[pb setString: nsStr forType: gtype];
}
+ [nsStr release];
}
}
{
NSString *type, *str;
const char *utfStr;
+ int length;
type = [pb availableTypeFromArray: ns_return_types];
if (type == nil)
options: NSLiteralSearch range: NSMakeRange (0, [mstr length])];
utfStr = [mstr UTF8String];
- if (!utfStr)
- utfStr = [mstr cString];
+ length = [mstr lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
+
+ if (!utfStr)
+ {
+ utfStr = [mstr cString];
+ length = strlen (utfStr);
+ }
}
NS_HANDLER
{
message1 ("ns_string_from_pasteboard: UTF8String failed\n");
utfStr = [str lossyCString];
+ length = strlen (utfStr);
}
NS_ENDHANDLER
- return build_string (utfStr);
+ return make_string (utfStr, length);
}