mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00

(https://github.com/ruby/strscan/pull/126)
Split off from https://github.com/ruby/ruby/pull/12322
9bee37e0f5
468 B
468 B
call-seq: charpos -> character_position
Returns the [character position][7] (initially zero), which may be different from the [byte position][2] given by method #pos:
scanner = StringScanner.new(HIRAGANA_TEXT)
scanner.string # => "こんにちは"
scanner.getch # => "こ" # 3-byte character.
scanner.getch # => "ん" # 3-byte character.
put_situation(scanner)
# Situation:
# pos: 6
# charpos: 2
# rest: "にちは"
# rest_size: 9