Comment by f1shy

Comment by f1shy 8 days ago

5 replies

There are other ways around without making the standard impossible to get right. Great, we have a standard that can cope with any alphabet... oh pitty that is impossible to write programs that use it correctly.

ks2048 8 days ago

It's tricky, but that's why nearly all of the time, you should use standard libraries. E.g., in Python, ".upper()" and ".capitalize()" does the work for you.

  • [removed] 7 days ago
    [deleted]
  • f1shy 7 days ago

    Does it have titleize() ?

    • ks2048 7 days ago

      That is capitalize()

      There's a note in the docs [0],

          Changed in version 3.8: The first character is now put into titlecase rather than uppercase. This means that characters like digraphs will only have their first letter capitalized, instead of the full character.
      
      [0] https://docs.python.org/3/library/stdtypes.html#str.capitali...

      EDIT: As the other reply says, ".title()" is probably a better answer to your question. Warning as the docs show [1], this splits things on sequence of letters, not whitespace!

          >>> "they're bill's friends from the UK".title()
      
          "They'Re Bill'S Friends From The Uk"
      
      
      [1] https://docs.python.org/3/library/stdtypes.html#str.title
    • o11c 7 days ago

      It's `.title()`, but note that it doesn't follow language-specific semantic rules like not capitalizing "the" and "of".