Permalink
Browse files

Encode all text sent from the websocket-send-text function.

This is necessary for non-ascii text.
  • Loading branch information...
1 parent 0efcdfe commit 29d8f2f1b8bd3d4dc452060e06ec407b0a6a8cf3 @ahyatt committed Sep 3, 2012
Showing with 13 additions and 2 deletions.
  1. +7 −0 websocket-test.el
  2. +6 −2 websocket.el
View
@@ -400,6 +400,13 @@
(should-not on-open-calledp)
(should websocket-closed-calledp))))))
+(ert-deftest websocket-send-text ()
+ (flet ((websocket-send (ws frame)
+ (should (equal
+ (websocket-frame-payload frame)
+ "\344\275\240\345\245\275"))))
+ (websocket-send-text nil "你好")))
+
(ert-deftest websocket-send ()
(let ((ws (websocket-inner-create :conn t :url t :accept-string t)))
(flet ((websocket-ensure-connected (websocket))
View
@@ -480,8 +480,12 @@ has connection termination."
(defun websocket-send-text (websocket text)
"To the WEBSOCKET, send TEXT as a complete frame."
- (websocket-send websocket (make-websocket-frame :opcode 'text :payload text
- :completep t)))
+ (websocket-send
+ websocket
+ (make-websocket-frame :opcode 'text
+ :payload (encode-coding-string
+ text 'raw-text)
+ :completep t)))
(defun websocket-check (frame)
"Check FRAME for correctness, returning true if correct."

0 comments on commit 29d8f2f

Please sign in to comment.