Index: chrome/common/extensions/docs/examples/api/nativeMessaging/host/native-messaging-example-host |
diff --git a/chrome/common/extensions/docs/examples/api/nativeMessaging/host/native-messaging-example-host b/chrome/common/extensions/docs/examples/api/nativeMessaging/host/native-messaging-example-host |
index 89da1c07373ccd1e7042e27f92e54f6b9678f685..8c94ed85c052cfe2da0d68f0bb2d823810600d08 100755 |
--- a/chrome/common/extensions/docs/examples/api/nativeMessaging/host/native-messaging-example-host |
+++ b/chrome/common/extensions/docs/examples/api/nativeMessaging/host/native-messaging-example-host |
@@ -17,6 +17,13 @@ try: |
except ImportError: |
Tkinter = None |
+# On Windows, the default I/O mode is O_TEXT. Set this to O_BINARY |
+# to avoid unwanted modifications of the input/output streams. |
+if sys.platform == "win32": |
+ import os, msvcrt |
+ msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
+ msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
+ |
# Helper function that sends a message to the webapp. |
def send_message(message): |
# Write message size. |