Workflow: Modify Clipboard Character Case05 Apr 2016
I haven’t posted about Workflow for a little while, but it remains one of my favourite applications on iOS and I’m still actively creating and revising workflows. In fact I’m currently clocking in at 176 workflows on my devices. Today I thought I’d clear up the dry spell on Workflow related posts and put something together around one of my text manipulation workflows. This particular one manipulates the character case of text on the device clipboard.
The workflow allows a user to modify the clipboard in the following ways.
- Upper Case - Convert all characters to upper case letters.
- Lower Case - Convert all characters to lower case letters.
- Title Case - Convert the first character of each principal word to upper case letters.
- Sentence Case - Convert the first character of each sentence to upper case to an upper case letter.
- Invert Case - Convert all upper case letters to lower case letters and all lower case letters to upper case letters.
- Capitalise Words - Convert the first character of each word to an upper case letter.
The table below shows how this works on a set of example text.
|Original||Would you like to visit FOO or B.a.R? actually Mike, QuZ has my vote. is that wrong?|
|Upper||WOULD YOU LIKE TO VISIT FOO OR B.A.R? ACTUALLY MIKE, QUZ HAS MY VOTE. IS THAT WRONG?|
|Lower||would you like to visit foo or b.a.r? actually mike, quz has my vote. is that wrong?|
|Title||Would You Like to Visit FOO or B.a.R? Actually Mike, QuZ Has My Vote. Is That Wrong?|
|Sentence||Would you like to visit FOO or B.a.R? actually Mike, QuZ has my vote. Is that wrong?|
|Invert||wOULD YOU LIKE TO VISIT foo OR b.A.r? ACTUALLY mIKE, qUz HAS MY VOTE. IS THAT WRONG?|
|Capitalise||Would You Like To Visit Foo Or B.A.R? Actually Mike, Quz Has My Vote. Is That Wrong?|
Note that at the time of writing (when I carried out the above conversions) the sentence case conversion in Workflow does not seem to recognise a question mark (?) as the end of a sentence.
When run, the workflow presents the user with a menu of conversion options. Upon selection the workflow grabs the clipboard content, runs the appropriate text conversion on it and then puts the resulting converted text on the clipboard (replacing the original text).
The upper, lower, title, sentence and capitalise conversions are all standard workflow text conversions. The invert case option however is not. The invert case option takes the text on the clipboard and inserts a string of five characters (“?rep?”). This string of characters is then used to separate each character out as a separate item. Each item is then in turn processed.
The character is converted to upper case and compared to its pre-upper cased self. If it is a match then the character must have started as an upper case character and so is converted to a lower case character. If not, then it is converted to an upper case character.
The converted character items are then recombined using a custom separator of no text at all. In effect a null string.
You can see the details of the workflow below and can also download it directly.
If you want to find out more about Workflow, why not take a look at the workflow section on this site?