unicode.case: slightly cleaner locale case handling.

db4
John Benediktsson 2012-08-30 11:32:12 -07:00
parent 0b8aa8efe0
commit d3fc7ef6c2
1 changed files with 16 additions and 10 deletions

View File

@ -17,10 +17,10 @@ SYMBOL: locale ! Just casing locale, or overall?
: replace ( old new str -- newstr )
[ split-subseq ] dip join ; inline
: i-dot? ( -- ? )
locale get { "tr" "az" } member? ;
: i-dot? ( locale -- ? )
{ "tr" "az" } member? ; inline
: lithuanian? ( -- ? ) locale get "lt" = ;
: lithuanian? ( locale -- ? ) "lt" = ; inline
: lithuanian>upper ( string -- lower )
"i\u000307" "i" replace
@ -80,19 +80,26 @@ SYMBOL: locale ! Just casing locale, or overall?
[ char-quot call out push ] ?if
] each out "" like ; inline
: locale>lower ( string -- string' )
locale get
[ i-dot? [ turk>lower ] when ]
[ lithuanian? [ lithuanian>lower ] when ] bi ;
: locale>upper ( string -- string' )
locale get
[ i-dot? [ turk>upper ] when ]
[ lithuanian? [ lithuanian>upper ] when ] bi ;
PRIVATE>
: >lower ( string -- lower )
i-dot? [ turk>lower ] when
lithuanian? [ lithuanian>lower ] when
final-sigma
locale>lower final-sigma
[ lower>> ] [ ch>lower ] map-case ;
HINTS: >lower string ;
: >upper ( string -- upper )
i-dot? [ turk>upper ] when
lithuanian? [ lithuanian>upper ] when
locale>upper
[ upper>> ] [ ch>upper ] map-case ;
HINTS: >upper string ;
@ -100,8 +107,7 @@ HINTS: >upper string ;
<PRIVATE
: (>title) ( string -- title )
i-dot? [ turk>upper ] when
lithuanian? [ lithuanian>upper ] when
locale>upper
[ title>> ] [ ch>title ] map-case ; inline
PRIVATE>