diff --git a/basis/unicode/case/case-docs.factor b/basis/unicode/case/case-docs.factor index a5790f9a54..86b791ed81 100644 --- a/basis/unicode/case/case-docs.factor +++ b/basis/unicode/case/case-docs.factor @@ -1,4 +1,4 @@ -USING: help.syntax help.markup ; +USING: help.syntax help.markup strings ; IN: unicode.case ABOUT: "unicode.case" @@ -9,6 +9,10 @@ ARTICLE: "unicode.case" "Case mapping" { $subsection >lower } { $subsection >title } { $subsection >case-fold } +"There are analogous routines which operate on individual code points, but these should " { $emphasis "not be used" } " in general as they have slightly different behavior. In some cases, for example, they do not perform the case operation, as a single code point must expand to more than one." +{ $subsection ch>upper } +{ $subsection ch>lower } +{ $subsection ch>title } "To test if a string is in a given case:" { $subsection upper? } { $subsection lower? } @@ -16,4 +20,51 @@ ARTICLE: "unicode.case" "Case mapping" { $subsection case-fold? } "For certain languages (Turkish, Azeri, Lithuanian), case mapping is dependent on locale; To change this, set the following variable to the ISO-639-1 code for your language:" { $subsection locale } -"This is unnecessary for most languages." ; +"This is unnecessary for most locales." ; + +HELP: >upper +{ $values { "string" string } { "upper" string } } +{ $description "Converts a string to upper case." } ; + +HELP: >lower +{ $values { "string" string } { "lower" string } } +{ $description "Converts a string to lower case." } ; + +HELP: >title +{ $values { "string" string } { "title" string } } +{ $description "Converts a string to title case." } ; + +HELP: >case-fold +{ $values { "string" string } { "case-fold" string } } +{ $description "Converts a string to case-folded form." } ; + +HELP: upper? +{ $values { "string" string } { "?" "a boolean" } } +{ $description "Tests if a string is in upper case." } ; + +HELP: lower? +{ $values { "string" string } { "?" "a boolean" } } +{ $description "Tests if a string is in lower case." } ; + +HELP: title? +{ $values { "string" string } { "?" "a boolean" } } +{ $description "Tests if a string is in title case." } ; + +HELP: case-fold? +{ $values { "string" string } { "?" "a boolean" } } +{ $description "Tests if a string is in case-folded form." } ; + +HELP: ch>lower +{ $values { "ch" "a code point" } { "lower" "a code point" } } +{ $description "Converts a code point to lower case." } +{ $warning "Don't use this unless you know what you're doing! " { $code ">lower" } " is not the same as " { $code "[ ch>lower ] map" } "." } ; + +HELP: ch>upper +{ $values { "ch" "a code point" } { "upper" "a code point" } } +{ $description "Converts a code point to upper case." } +{ $warning "Don't use this unless you know what you're doing! " { $code ">upper" } " is not the same as " { $code "[ ch>upper ] map" } "." } ; + +HELP: ch>title +{ $values { "ch" "a code point" } { "title" "a code point" } } +{ $description "Converts a code point to title case." } +{ $warning "Don't use this unless you know what you're doing! " { $code ">title" } " is not the same as " { $code "[ ch>title ] map" } "." } ; diff --git a/basis/unicode/case/case.factor b/basis/unicode/case/case.factor index 42fd13fc97..7e61831f36 100644 --- a/basis/unicode/case/case.factor +++ b/basis/unicode/case/case.factor @@ -7,12 +7,14 @@ IN: unicode.case : ch>lower ( ch -- lower ) simple-lower at-default ; : ch>upper ( ch -- upper ) simple-upper at-default ; : ch>title ( ch -- title ) simple-title at-default ; -PRIVATE> + SYMBOL: locale ! Just casing locale, or overall? + char } +{ $subsection char>name } +{ $subsection property? } ; + +HELP: load-script +{ $value { "filename" string } { "table" "an interval map" } } +{ $description "This loads a file that looks like Script.txt in the Unicode Character Database and converts it into an efficient interval map, where the keys are characters and the values are strings for the properties." } ; + +HELP: canonical-entry +{ $value { "char" "a code point" } { "seq" string } } +{ $description "Finds the canonical decomposition (NFD) for a code point" } ; + +HELP: combine-chars +{ $value { "a" "a code point" } { "b" "a code point" } { "char/f" "a code point" } } +{ $description "If a followed by b can be combined in NFC, this returns the code point of their combination." } ; + +HELP: compatibility-entry +{ $value { "char" "a code point" } { "seq" string } } +{ $description "This returns the compatibility decomposition (NFKD) for a code point" } ; + +HELP: combining-class +{ $value { "char" "a code point" } { "n" "an integer" } } +{ $description "Finds the combining class of a code point." } ; + +HELP: non-starter? +{ $value { "char" "a code point" } { "?" "a boolean" } } +{ $description "Returns true if the code point has a combining class." } ; + +HELP: char>name +{ $value { "char" "a code point" } { "name" string } } +{ $description "Looks up the name of a given code point. Warning: this is not optimized for speed, to save space." } ; + +HELP: name>char +{ $value { "name" string } { "char" "a code point" } } +{ $description "Looks up the code point corresponding to a given name." } ; + +HELP: property? +{ $value { "char" "a code point" } { "property" string } { "?" "a boolean" } } +{ $description "Tests whether the code point is listed under the given property in PropList.txt in the Unicode Character Database." } ;