on master help sign in
Fix behaviour of toTitle

It was not previously lowercasing letters following the first in a word. --HG-- extra : amend_source : 18e3e759e78f9950bdd818e47cbc9a10c6deedaa

commit9af7c1de8f388320e8519596e0fb1cb6775606b7 authorBryan O'Sullivan <bos@serpentine.com> dateSat 30 Nov 2013, 23:27 (13 years ago) parent8ee20a0
3 files changed+19−17
Data/Text.hs+4−4 Data/Text/Fusion/Common.hs+11−9 Data/Text/Lazy.hs+4−4
Data/Text.hs+4−4
@@ -688,10 +688,10 @@ toUpper t = unstream (S.toUpper (stream t))
688688-- | /O(n)/ Convert a string to title case, using simple case
689689-- conversion. Subject to fusion.
690690--
691−-- Unlike the other case conversion functions, this function does not
692−-- convert every letter of its input. Instead, the first letter is
693−-- converted to title case, as is every subsequent letter that
694−-- immediately follows a non-letter.
691+-- The first letter of the input is converted to title case, as is
692+-- every subsequent letter that immediately follows a non-letter.
693+-- Every letter that immediately follows another letter is converted
694+-- to lower case.
695695--
696696-- The result string may be longer than the input string. For example,
697697-- the Latin small ligature &#xfb02; (U+FB02) is converted to the
Data/Text/Fusion/Common.hs+11−9
@@ -438,10 +438,10 @@ toLower = caseConvert lowerMapping
438438-- | /O(n)/ Convert a string to title case, using simple case
439439-- conversion.
440440--
441−-- Unlike the other case conversion functions, this function does not
442−-- convert every letter of its input. Instead, the first letter is
443−-- converted to title case, as is every subsequent letter that
444−-- immediately follows a non-letter.
441+-- The first letter of the input is converted to title case, as is
442+-- every subsequent letter that immediately follows a non-letter.
443+-- Every letter that immediately follows another letter is converted
444+-- to lower case.
445445--
446446-- The result string may be longer than the input string. For example,
447447-- the Latin small ligature &#xfb02; (U+FB02) is converted to the
@@ -458,13 +458,15 @@ toTitle (Stream next0 s0 len) = Stream next (CC (False :*: s0) '\0' '\0') len
458458 where
459459 next (CC (letter :*: s) '\0' _) =
460460 case next0 s of
461− Done -> Done
462− Skip s' -> Skip (CC (letter :*: s') '\0' '\0')
461+ Done -> Done
462+ Skip s' -> Skip (CC (letter :*: s') '\0' '\0')
463463 Yield c s'
464− | not letter && letter' -> titleMapping c (letter' :*: s')
465− | otherwise -> Yield c (CC (letter' :*: s') '\0' '\0')
464+ | letter' -> if letter
465+ then lowerMapping c (letter' :*: s')
466+ else titleMapping c (letter' :*: s')
467+ | otherwise -> Yield c (CC (letter' :*: s') '\0' '\0')
466468 where letter' = isLetter c
467− next (CC s a b) = Yield a (CC s b '\0')
469+ next (CC s a b) = Yield a (CC s b '\0')
468470{-# INLINE [0] toTitle #-}
469471
470472justifyLeftI :: Integral a => a -> Char -> Stream Char -> Stream Char
Data/Text/Lazy.hs+4−4
@@ -707,10 +707,10 @@ toUpper t = unstream (S.toUpper (stream t))
707707-- | /O(n)/ Convert a string to title case, using simple case
708708-- conversion. Subject to fusion.
709709--
710−-- Unlike the other case conversion functions, this function does not
711−-- convert every letter of its input. Instead, the first letter is
712−-- converted to title case, as is every subsequent letter that
713−-- immediately follows a non-letter.
710+-- The first letter of the input is converted to title case, as is
711+-- every subsequent letter that immediately follows a non-letter.
712+-- Every letter that immediately follows another letter is converted
713+-- to lower case.
714714--
715715-- The result string may be longer than the input string. For example,
716716-- the Latin small ligature &#xfb02; (U+FB02) is converted to the