Method: PlainText.count_char
- Defined in:
- lib/plain_text.rb
.count_char(instr, *rest, lbs_style: , linehead_style: , lastsps_style: , lb_out: , **k) ⇒ Integer
Count the number of characters
See #clean_text! for the optional parameters. The defaults of a few of the optional parameters are different from it, such as the default for lb_out is “n” (newline, so that a line-break is 1 byte in size). It is so that this method is more optimized for East-Asian (CJK) characters, given this method is most useful for CJK Strings, whereas, for European alphabets, counting the number of words, rather than characters as in this method, would be more standard.
91 92 93 94 95 96 97 98 99 |
# File 'lib/plain_text.rb', line 91 def self.count_char(instr, *rest, lbs_style: DEF_METHOD_OPTS[:count_char][:lbs_style], linehead_style: DEF_METHOD_OPTS[:count_char][:linehead_style], lastsps_style: DEF_METHOD_OPTS[:count_char][:lastsps_style], lb_out: DEF_METHOD_OPTS[:count_char][:lb_out], **k ) clean_text(instr, *rest, lbs_style: lbs_style, linehead_style: linehead_style, lastsps_style: lastsps_style, lb_out: lb_out, **k).size end |