diff --git a/basis/ascii/ascii-docs.factor b/basis/ascii/ascii-docs.factor index 4c783e609c..b2bbc16836 100644 --- a/basis/ascii/ascii-docs.factor +++ b/basis/ascii/ascii-docs.factor @@ -57,8 +57,10 @@ HELP: >upper { $values { "str" "a string" } { "upper" "a string" } } { $description "Converts an ASCII string to upper case." } ; -ARTICLE: "ascii" "ASCII character classes" -"The " { $vocab-link "ascii" } " vocabulary implements traditional ASCII character classes:" +ARTICLE: "ascii" "ASCII" +"The " { $vocab-link "ascii" } " vocabulary implements support for the legacy ASCII character set. Most applications should use " { $link "unicode" } " instead." +$nl +"ASCII character classes:" { $subsection blank? } { $subsection letter? } { $subsection LETTER? } @@ -67,11 +69,10 @@ ARTICLE: "ascii" "ASCII character classes" { $subsection control? } { $subsection quotable? } { $subsection ascii? } -"ASCII case conversion is also implemented:" +"ASCII case conversion:" { $subsection ch>lower } { $subsection ch>upper } { $subsection >lower } -{ $subsection >upper } -"Modern applications should use Unicode 5.1 instead (" { $vocab-link "unicode.categories" } ")." ; +{ $subsection >upper } ; ABOUT: "ascii" diff --git a/basis/ascii/ascii.factor b/basis/ascii/ascii.factor index a64a7b8eb5..193e847d27 100644 --- a/basis/ascii/ascii.factor +++ b/basis/ascii/ascii.factor @@ -1,41 +1,23 @@ -! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel math math.order sequences -combinators.short-circuit ; +USING: kernel math math.order sequences strings +combinators.short-circuit hints ; IN: ascii : ascii? ( ch -- ? ) 0 127 between? ; inline - : blank? ( ch -- ? ) " \t\n\r" member? ; inline - : letter? ( ch -- ? ) CHAR: a CHAR: z between? ; inline - : LETTER? ( ch -- ? ) CHAR: A CHAR: Z between? ; inline - : digit? ( ch -- ? ) CHAR: 0 CHAR: 9 between? ; inline - : printable? ( ch -- ? ) CHAR: \s CHAR: ~ between? ; inline +: control? ( ch -- ? ) "\0\e\r\n\t\u000008\u00007f" member? ; inline +: quotable? ( ch -- ? ) { [ printable? ] [ "\"\\" member? not ] } 1&& ; inline +: Letter? ( ch -- ? ) { [ letter? ] [ LETTER? ] } 1|| ; inline +: alpha? ( ch -- ? ) { [ Letter? ] [ digit? ] } 1|| ; inline +: ch>lower ( ch -- lower ) dup LETTER? [ HEX: 20 + ] when ; inline +: >lower ( str -- lower ) [ ch>lower ] map ; +: ch>upper ( ch -- upper ) dup letter? [ HEX: 20 - ] when ; inline +: >upper ( str -- upper ) [ ch>upper ] map ; -: control? ( ch -- ? ) - "\0\e\r\n\t\u000008\u00007f" member? ; inline - -: quotable? ( ch -- ? ) - dup printable? [ "\"\\" member? not ] [ drop f ] if ; inline - -: Letter? ( ch -- ? ) - [ [ letter? ] [ LETTER? ] ] 1|| ; - -: alpha? ( ch -- ? ) - [ [ Letter? ] [ digit? ] ] 1|| ; - -: ch>lower ( ch -- lower ) - dup CHAR: A CHAR: Z between? [ HEX: 20 + ] when ; - -: >lower ( str -- lower ) - [ ch>lower ] map ; - -: ch>upper ( ch -- upper ) - dup CHAR: a CHAR: z between? [ HEX: 20 - ] when ; - -: >upper ( str -- upper ) - [ ch>upper ] map ; +HINTS: >lower string ; +HINTS: >upper string ; \ No newline at end of file