Expand/Shrink

proper

Definition: string res = proper(string s, method="CAPITALISE")
Description: Perform selected upper/lowercase operations on a string.

s: the string to be modified
method: one of "LOWER","UPPER","CAPITALISE","SENTENCE","INVERT".

Obviously LOWER/UPPER overlap functionally with lower()/upper(), but it might be useful to dynamically specify such options at runtime.
SENTENCE is far from perfect, INVERT has (potential) use in Edita/Edix, to correct something just typed in with the wrong caps lock setting, and it is probably not a bad idea to retry failed passwords using that option.
pwa/p2js: Supported.
Example:
constant s = "this is England. so there",
         methods = {"LOWER","UPPER","CAPITALISE","SENTENCE","INVERT"}
for i=1 to length(methods) do
    printf(1,"%s (%s case)\n",{proper(s,methods[i]),proper(methods[i])})
end for
-- Output:
--  this is england. so there (Lower case)
--  THIS IS ENGLAND. SO THERE (Upper case)
--  This Is England. So There (Capitalise case)
--  This is england. So there (Sentence case)
--  THIS IS eNGLAND. SO THERE (Invert case)
Implementation: See builtins\pcase.e (an autoinclude) for details of the actual implementation.
See Also: upper, lower
Expand/Shrink