在 OSX PasteBoard/剪贴板之间复制和粘贴 utf-8 文本的教程/指南
我目前正在向我的 gui API 添加剪贴板支持。它以 UTF-8 作为 std 字符串输入和输出。
我现在需要添加 OSX 支持,但我几乎没有 Objective-C 的经验。是否有某种教程可以显示与 std::string 的交互,从 utf-8 转换为 osx 本机使用的任何内容,然后将其复制到剪贴板,反之亦然?
谢谢,
我只是希望能够获取 utf-8 编码的 std 字符串并将其复制到 osx 剪贴板,并且能够从 textedit 等复制一些文本并将其作为 UTF-8 字符串粘贴到我的应用程序中。
I'm currently adding clipboard support to my gui API. It inputs and outputs in UTF-8 as std string.
I now need to add OSX support but I have almost no experience with Objective-C. Is there some sort of tutorial that might show interaction with std::string, converting from utf-8 to whatever osx natively uses, then copying it to the clipboard and vice versa?
Thanks
I just want to be able to take a utf-8 encoded std string and copy it to osx clipboard and to be able to copy some text from something like textedit and paste it into my application as a UTF-8 string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Cocoa 中的字符串类是 NSString
NSString initWithUTF8String
用于从 UTF-8 char* 创建 Cocoa 字符串NSString UTF8String
反之亦然用于简单粘贴
http://www.cocoadev.com/index.pl?CopyAndPaste
The string class is NSString in Cocoa
NSString initWithUTF8String
to create a cocoa string from UTF-8 char*NSString UTF8String
for vice versaFor simple pasting
http://www.cocoadev.com/index.pl?CopyAndPaste