Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6423415

(str) Add String.toTitleCase()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 5.0
    • core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      Such a method would convert the first code point of the string to title case.

      Surely such a routine is being used in all sorts of applications. A naïve approach might be:

      public String toTitleCase() {
        if (length() == 0) return this;
        char firstChar = charAt(0);
        firstChar = Character.toTitleCase(firstChar);
        return firstChar + substring(1);
      }

      Even this method seems non-trivial and used often enough to warrant adding to the API. However this method doesn't take into account code points and locales. Surely these complexities are enough to warrant an addition to the API.

      JUSTIFICATION :
      Such an operation seems non-trivial to me, especially given that the first code point may be made up of more than one character.

            jgish Jim Gish (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: