Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tc, tclc, and tcuc.

  • Loading branch information...
commit be8bdf4f524126846a258c79154595d34dd1835c 1 parent 442e075
@colomon colomon authored
Showing with 16 additions and 0 deletions.
  1. +11 −0 lib/CORE.setting
  2. +5 −0 lib/UCD.cs
View
11 lib/CORE.setting
@@ -685,6 +685,15 @@ my class Cool {
}
method lc() { Q:CgOp { (box Str (str_tolower (obj_getstr {self}))) }}
method uc() { Q:CgOp { (box Str (str_toupper (obj_getstr {self}))) }}
+ method tc() {
+ self ~~ /^(.)(.*)$/ ?? Q:CgOp { (box Str (ucd_titlecase { $0.ord })) } ~ $1 !! "";
+ }
+ method tclc() {
+ self ~~ /^(.)(.*)$/ ?? Q:CgOp { (box Str (ucd_titlecase { $0.ord })) } ~ $1.lc !! "";
+ }
+ method tcuc() {
+ self ~~ /^(.)(.*)$/ ?? Q:CgOp { (box Str (ucd_titlecase { $0.ord })) } ~ $1.uc !! "";
+ }
method flip() { Q:CgOp { (box Str (str_flip (obj_getstr {self}))) }}
method ucfirst() { ucfirst(self) }
method lcfirst() { lcfirst(self) }
@@ -1307,6 +1316,8 @@ sub infix:<leg> is pure is Niecza::absprec<n= non> is diffy ($s1, $s2) {
sub lc($string) is pure { (~$string).lc }
sub uc($string) is pure { (~$string).uc }
+sub tc($string) is pure { (~$string).tc }
+sub tclc($string) is pure { (~$string).tclc }
sub chop($string) is pure { (~$string).chop }
sub chomp($string) is pure { (~$string).chomp }
sub capitalize($string) is pure { (~$string).capitalize }
View
5 lib/UCD.cs
@@ -682,4 +682,9 @@ public partial class Builtins {
return MakeStr(DataSet.GetCodepoint(
ch.Fetch().mo.mro_raw_Str.Get(ch)));
}
+
+ public static string ucd_titlecase(Variable ch) {
+ Property p = (Property) DataSet.GetTable("tc");
+ return p.GetValue((int) ch.Fetch().mo.mro_raw_Numeric.Get(ch));
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.