Return unicode string in clipboard.readText(), fixes atom/atom#2145.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 5 Jun 2014 03:43:45 +0000 (11:43 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 5 Jun 2014 03:43:45 +0000 (11:43 +0800)
atom/common/api/atom_api_clipboard.cc
spec/api-clipboard-spec.coffee [new file with mode: 0644]

index e98c2f2..0789f51 100644 (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;
 }
 
diff --git a/spec/api-clipboard-spec.coffee b/spec/api-clipboard-spec.coffee
new file mode 100644 (file)
index 0000000..eecf61c
--- /dev/null
@@ -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