Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Unified Diff: remoting/host/clipboard_util.cc

Issue 10441131: [Chromoting] Handle CR-LF correctly when transferring text items to and from the clipboard on a Win… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/clipboard_util.h ('k') | remoting/host/clipboard_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/clipboard_util.cc
diff --git a/remoting/host/clipboard_util.cc b/remoting/host/clipboard_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..87ef7cf1f09ae31827a92d6a8d0ca159a6e39537
--- /dev/null
+++ b/remoting/host/clipboard_util.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/clipboard_util.h"
+
+namespace remoting {
+
+std::string ClipboardUtil::ReplaceLfByCrLf(const std::string& in) {
Wez 2012/05/31 22:36:41 This and the reverse can be implemented with Repla
+ std::string out;
+ out.resize(2 * in.size());
+ char* out_p_begin = &out[0];
+ char* out_p = out_p_begin;
+ const char* in_p_begin = &in[0];
+ const char* in_p_end = &in[in.size()];
+ for (const char* in_p = in_p_begin; in_p < in_p_end; ++in_p) {
+ char c = *in_p;
+ if (c == '\n') {
+ *out_p++ = '\r';
+ }
+ *out_p++ = c;
+ }
+ out.resize(out_p - out_p_begin);
+ return out;
+}
+
+std::string ClipboardUtil::ReplaceCrLfByLf(const std::string& in) {
+ std::string out;
+ out.resize(in.size());
+ char* out_p_begin = &out[0];
+ char* out_p = out_p_begin;
+ const char* in_p_begin = &in[0];
+ const char* in_p_end = &in[in.size()];
+ for (const char* in_p = in_p_begin; in_p < in_p_end; ++in_p) {
+ char c = *in_p;
+ if ((c == '\r') && (in_p + 1 < in_p_end) && (*(in_p + 1) == '\n')) {
+ *out_p++ = '\n';
+ ++in_p;
+ } else {
+ *out_p++ = c;
+ }
+ }
+ out.resize(out_p - out_p_begin);
+ return out;
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/clipboard_util.h ('k') | remoting/host/clipboard_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698