Page 1 of 1

FIXED? Discrepancy between script and menu command output

Posted: 28 Feb 2021 13:03
by pjj
Here's an exemplary text:

Code: Select all

one two
"one two"
(one two)
one-two
one_two
one+two
one,two
When I run RMC > Change Case > Capitalize command (or Edit > Format > Change Case > Capitalize), I get this:

Code: Select all

One Two
"One Two"
(One Two)
One-Two
One_two
One+Two
One,Two
However, with a Namecase function in my script I get this:

Code: Select all

One Two
"one Two"
(one Two)
One-two
One_two
One+two
One,two
I'd say the former output is almost correct -- IMO it should give One_Two. Can you please make Namecase work the way menu command does (with possible change for text with underscores)?

And to mitigate confusion, perhaps Namecase function should be renamed to Capitalize, with Namecase as an alias.

Re: Discrepancy between script and menu command output

Posted: 28 Feb 2021 14:58
by Rickard Johansson
Added script function "Document.Capitalize()" in next release (v14.73).

The function seems to be working correctly though. I've tested against different rules like:

* Chicago Manual of Style capitalization rules.
* NY Times style guidelines.

You can always write your own Capitalize function to use in scripts, you know :wink:

Re: FIXED? Discrepancy between script and menu command output

Posted: 28 Feb 2021 16:22
by pjj
:?

Perhaps I expressed myself not clearly enough. I didn't mean capitalization as in "title capitalization" (as covered by, among other similar style guides, Chicago Manual of Style); what I meant was converting a string to a so called title case (or proper case, cf. e.g. http://string-functions.com/case.aspx ):

Code: Select all

one two => One Two
"one two" => "One Two"
etc. This is done properly by menu command, while Namecase function does it differently. If Capitalize() is going to mimic menu command's behavior, I am happy and don't care about Namecase().

Re: FIXED? Discrepancy between script and menu command output

Posted: 28 Feb 2021 18:05
by Rickard Johansson
The script function "Document.Capitalize()" is the same as in the menus. There are many ways to capitalize and I might add some more to both the menus and the script engine at some point...

Re: FIXED? Discrepancy between script and menu command output

Posted: 28 Feb 2021 19:54
by pjj
Wonderful, thanks! As for the "title capitalization" (as opposed to string capitalization), I don't think it's worth it. First of all, it may be needed by editors rather than programmers; second of all, it should take into account string's language, because each one has its own rules, cf. e.g. TextInfo.ToTitleCase(String) Method. Just my 2 cc, though.