Return unicode string in clipboard.readText(), fixes atom/atom#2145.

This commit is contained in:
Cheng Zhao 2014-06-05 11:43:45 +08:00
parent ac1a03bf9c
commit 7c14c2758b
2 changed files with 13 additions and 3 deletions

View file

@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include "atom/common/native_mate_converters/string16_converter.h"
#include "native_mate/dictionary.h"
#include "ui/base/clipboard/clipboard.h"
@ -27,11 +28,11 @@ std::string Read(const std::string& format_string) {
return data;
}
std::string ReadText() {
string16 ReadText() {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
std::string data;
clipboard->ReadAsciiText(ui::Clipboard::BUFFER_STANDARD, &data);
string16 data;
clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &data);
return data;
}

View file

@ -0,0 +1,9 @@
assert = require 'assert'
clipboard = require 'clipboard'
describe 'clipboard module', ->
describe 'clipboard.readText()', ->
it 'returns unicode string correctly', ->
text = '千江有水千江月,万里无云万里天'
clipboard.writeText text
assert.equal clipboard.readText(), text