Presumably there's an excellent reason not to use l3 syntax because egreg has not written an answer.
Also note: I do not know what I'm doing.
Caveat emptor...
The expl3 package is used to enable l3 syntax. (The LaTeX equivalent of the latest thing since sliced bread.) xparse is used to easily define a starred form of the command which excludes spaces from the character count.
Because l3 is oblivious to spaces by default, the extra work actually goes into the non-starred form of the command which converts all spaces to xs before doing the count.
Note that this solution will count accented characters as decomposed with pdfTeX. With Xe/LuaTeX, it works provided a font supporting the characters is used. Thanks to comments for discussion.
\ExplSyntaxOn % enable l3 syntax
\tl_new:N \l_qzx_string_tl % declare a local token list to hold qzx's string
\NewDocumentCommand \numchars { s m }{ % command optionally takes a star and requires a single argument
\group_begin:
\tl_set:Nn \l_qzx_string_tl { #2 } % set the token list to the string we've been fed
\IfBooleanF { #1 } % if there is no star
{ % then replace all instances of a space (~ in l3 syntax) by instances of x
\tl_replace_all:Nnn \l_qzx_string_tl { ~ } { x }
}
% the count of the characters in the token list goes straight into the stream to be typeset but we need to add the spaces we want here explicitly using ~
\noindent The~string~``#2"~has~\tl_count:N \l_qzx_string_tl{}~characters.\par % use \par rather than \\ to avoid complaints about bad boxes
\group_end:
}
\ExplSyntaxOff% turn l3 syntax off so everything is back to normal and giraffes are giraffes once more

Complete code:
\documentclass{article}
\usepackage{expl3,xparse}
\ExplSyntaxOn
\tl_new:N \l_qzx_string_tl
\NewDocumentCommand \numchars { s m }{
\group_begin:
\tl_set:Nn \l_qzx_string_tl { #2 }
\IfBooleanF { #1 }
{
\tl_replace_all:Nnn \l_qzx_string_tl { ~ } { x }
}
\noindent The~string~``#2"~has~\tl_count:N \l_qzx_string_tl{}~characters.\par
\group_end:
}
\ExplSyntaxOff
\begin{document}
\numchars{everything}
\numchars*{everything}
\numchars{that's not it!}
\numchars*{that's not it!}
\numchars{weird}
\numchars*{weird}
\numchars{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.}
\numchars*{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.}
\end{document}
This will certainly break if fed wonderful things before breakfast, is likely to feel a little fragile prior to lunch and will probably need to spend the afternoon recovering before getting an early night.
As I said, caveat emptor....