Permalink
Browse files

Use ".codePointCount" to calculate the length of a rpc message string…

…, refs #62

Java Unicode surrogate pairs consists of two chars and thus results in
an invalid length when ".length" is used to calculate the packet
length.
  • Loading branch information...
1 parent 1b68515 commit e2b5c3e2df0b7eeffd6cfb7be388f6d07a4e01f0 @juergenhoetzel juergenhoetzel committed with hugoduncan Dec 1, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 swank/src/ritz/swank/rpc.clj
@@ -130,7 +130,7 @@ protocol. Code from Terje Norderhaug <terje@in-progress.com>."
(defn- write-packet
[^Writer writer ^String str]
- (let [len (.length str)]
+ (let [len (.codePointCount str 0 (.length str))]
(doto writer
(.write (format "%06x" len))
(.write str)

0 comments on commit e2b5c3e

Please sign in to comment.