Skip to content

The unicode library

tim-hardcastle edited this page Oct 20, 2024 · 4 revisions

The unicode library in Pipefish wraps around the standard unicode library in Go. As usual, the function names have been converted from PascalCase to camelCase.

Besides that:

  • The To function has been renamed toCase, and takes an enum of type Case as its first parameter.

  • The In and Is and IsOneOf functions have been amalgamated into single function isIn which as its second parameter takes a varargs of pairs specifying lower and upper bounds, e.g. unicode.isIn r, 64::91, 97::123 wil test if the rune r is in the alphabetical part of ASCII. As always, ranges include the smaller value and exclude the larger.

The API of the library therefore consists of the Case type:

Case = enum UPPER_CASE, LOWER_CASE, TITLE_CASE, MAX_CASE

... and a collection of functions with signatures as follows:

  • isControl(r rune) -> bool
  • isDigit(r rune) -> bool
  • isGraphic(r rune) -> bool
  • isIn(r rune, bounds ... pair) -> bool
  • isLetter(r rune) -> bool
  • isLower(r rune) -> bool
  • isMark(r rune) -> bool
  • isNumber(r rune) -> bool
  • isPrint(r rune) -> bool
  • isPunct(r rune) -> bool
  • isSpace(r rune) -> bool
  • isSymbol(r rune) -> bool
  • isTitle(r rune) -> bool
  • isUpper(r rune) -> bool
  • simpleFold(r rune) -> rune
  • toCase(c Case, r rune) -> rune
  • toLower(r rune) -> rune
  • toTitle(r rune) -> rune
  • toUpper(r rune) -> rune
Clone this wiki locally