Pasteboard Viewer is a useful tool to show exactly what’s on the pasteboard, so it should show it in the lowest-level format. However, when strings are encoded as UTF-16 they are interpreted.
For example, compile and run:
// save as pasteboard8.m, compile with
// cc pasteboard8.m -o pasteboard8 -framework AppKit
#import <AppKit/AppKit.h>
int main() {
NSPasteboard* pb = NSPasteboard.generalPasteboard;
[pb clearContents];
[pb setData:[@"<html><p>hi</html>" dataUsingEncoding:NSUTF8StringEncoding] forType:NSPasteboardTypeHTML];
}
If you run that, and then use Pasteboard Viewer, you get:
Perfect. Now compile and run:
// save as pasteboard16.m, compile with
// cc pasteboard16.m -o pasteboard16 -framework AppKit
#import <AppKit/AppKit.h>
int main() {
NSPasteboard* pb = NSPasteboard.generalPasteboard;
[pb clearContents];
// Loaded and displayed as the actual HTML contents:
[pb setData:[@"<html><p>hi</html>" dataUsingEncoding:NSUTF16StringEncoding] forType:NSPasteboardTypeHTML];
}
If you run that, and then use Pasteboard Viewer, you get:
which interprets the data as HTML and loads the styled string.
It would be best if the raw string were shown, even if it is encoded other than UTF-8.
Pasteboard Viewer is a useful tool to show exactly what’s on the pasteboard, so it should show it in the lowest-level format. However, when strings are encoded as UTF-16 they are interpreted.
For example, compile and run:
If you run that, and then use Pasteboard Viewer, you get:
Perfect. Now compile and run:
If you run that, and then use Pasteboard Viewer, you get:
which interprets the data as HTML and loads the styled string.
It would be best if the raw string were shown, even if it is encoded other than UTF-8.