Word Count Algorithm

I’m not asking for the secret sauce so much as how much pepper you use, but what is Scrivener’s word count algorithm? I’m trying to write up some code to do automatic word count tallies and store them in a spreadsheet, and I wanted to keep them in line with what Scrivener thinks is going on.

I know I can write my own word count algo, but I was hoping to stay consistent. :slight_smile:

Are you using Cocoa? I use NSAttributedString’s -nextWordFromIndex:forward: method to calculate words (the code for Scrivener’s word counting is actually available here: literatureandlatte.com/freestuff.php - KBWordCountingTextStorage). If you’re not using Cocoa, then it will be difficult, because what gets defined as a word is down to Apple’s -nextWordFromIndex:… method, and there is no specific documentation anywhere explaining how that defines words.

Ok, so you’re actually counting the words instead of (character count / N). I’m not using Cocoa, but that tells me what I needed to know. Thanks.