1.1 --- a/src/Pure/library.scala Sat Apr 12 21:00:04 2014 +0200
1.2 +++ b/src/Pure/library.scala Sat Apr 12 21:38:38 2014 +0200
1.3 @@ -103,12 +103,19 @@
1.4
1.5 /* strings */
1.6
1.7 - def lowercase(str: String): String = str.toLowerCase(Locale.ENGLISH)
1.8 - def uppercase(str: String): String = str.toUpperCase(Locale.ENGLISH)
1.9 + def lowercase(str: String, locale: Locale = Locale.ENGLISH): String = str.toLowerCase(locale)
1.10 + def uppercase(str: String, locale: Locale = Locale.ENGLISH): String = str.toUpperCase(locale)
1.11
1.12 - def capitalize(str: String): String =
1.13 + def capitalize(str: String, locale: Locale = Locale.ENGLISH): String =
1.14 if (str.length == 0) str
1.15 - else uppercase(str.substring(0, 1)) + str.substring(1)
1.16 + else uppercase(str.substring(0, 1), locale) + str.substring(1)
1.17 +
1.18 + def is_capitalized(str: String): Boolean =
1.19 + str.length > 0 &&
1.20 + Character.isUpperCase(str(0)) && str.substring(1).forall(Character.isLowerCase(_))
1.21 +
1.22 + def is_all_caps(str: String): Boolean =
1.23 + str.length > 0 && str.forall(Character.isUpperCase(_))
1.24
1.25 def try_unprefix(prfx: String, s: String): Option[String] =
1.26 if (s.startsWith(prfx)) Some(s.substring(prfx.length)) else None