14
14
defdirectives formatter-out]])
15
15
(:require
16
16
[cljs.core :refer [IWriter IDeref]]
17
- [clojure.string :as string])
17
+ [clojure.string :as string]
18
+ [goog.string :as gstring])
18
19
(:import [goog.string StringBuffer]))
19
20
20
21
(def ^:dynamic *out* nil )
@@ -1956,19 +1957,12 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
1956
1957
; ;TODO need to enforce integers only?
1957
1958
(-write writer (string/upper-case (char c))))))))
1958
1959
1959
- ; ;TODO: This is an oversimplied version. Needs to be fully implemented
1960
- (defn- is-letter? [s]
1961
- (boolean
1962
- (#{" A" " B" " C" " D" " E" " F" " G" " H" " I" " J" " K" " L" " M" " N" " O" " P" " Q" " R" " S" " T" " U" " V" " W" " X" " Y" " Z"
1963
- " a" " b" " c" " d" " e" " f" " g" " h" " i" " j" " k" " l" " m" " n" " o" " p" " q" " r" " s" " t" " u" " v" " w" " x" " y" " z" }
1964
- s)))
1965
-
1966
1960
(defn- capitalize-string
1967
1961
" Capitalizes the words in a string. If first? is false, don't capitalize the
1968
1962
first character of the string even if it's a letter."
1969
1963
[s first?]
1970
1964
(let [f (first s)
1971
- s (if (and first? f (is-letter? f))
1965
+ s (if (and first? f (gstring/isUnicodeChar f))
1972
1966
(str (string/upper-case f) (subs s 1 ))
1973
1967
s)]
1974
1968
(apply str
@@ -1986,11 +1980,6 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
1986
1980
[s nil ]))))
1987
1981
s)))))
1988
1982
1989
- ; ;TODO: This is an oversimplied version. Needs to be fully implemented
1990
- (defn- is-whitespace? [s]
1991
- (boolean
1992
- (#{\space \newline} s)))
1993
-
1994
1983
(defn- capitalize-word-writer
1995
1984
" Returns a proxy that wraps writer, capitalizing all words"
1996
1985
[writer]
@@ -2009,13 +1998,13 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
2009
1998
(-write writer
2010
1999
(capitalize-string (.toLowerCase s) @last-was-whitespace?))
2011
2000
(when (pos? (.-length s))
2012
- (reset! last-was-whitespace? (is-whitespace? (nth s (dec (count s)))))))
2001
+ (reset! last-was-whitespace? (gstring/isEmptyOrWhitespace (nth s (dec (count s)))))))
2013
2002
2014
2003
js/Number
2015
2004
(let [c (char x)]
2016
2005
(let [mod-c (if @last-was-whitespace? (string/upper-case c) c)]
2017
2006
(-write writer mod-c)
2018
- (reset! last-was-whitespace? (is-whitespace? c)))))))))
2007
+ (reset! last-was-whitespace? (gstring/isEmptyOrWhitespace c)))))))))
2019
2008
2020
2009
(defn- init-cap-writer
2021
2010
" Returns a proxy that wraps writer, capitalizing the first word"
@@ -2046,7 +2035,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
2046
2035
2047
2036
js/Number
2048
2037
(let [c (char x)]
2049
- (if (and (not @capped) (is-letter? c))
2038
+ (if (and (not @capped) (gstring/isUnicodeChar c))
2050
2039
(do
2051
2040
(reset! capped true )
2052
2041
(-write writer (string/upper-case c)))
0 commit comments