Skip to content

Commit 7c4dbd4

Browse files
committed
Replaced examples using $KCODE with encodings
`$KCODE` has been deprecated and not effective since years ago.
1 parent 6f5158c commit 7c4dbd4

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ext/strscan/strscan.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,8 @@ adjust_registers_to_matched(struct strscanner *p)
848848
* s.getch # => "b"
849849
* s.getch # => nil
850850
*
851-
* $KCODE = 'EUC'
852-
* s = StringScanner.new("\244\242")
853-
* s.getch # => "\244\242" # Japanese hira-kana "A" in EUC-JP
851+
* s = StringScanner.new("\244\242".force_encoding("euc-jp"))
852+
* s.getch # => "\x{A4A2}" # Japanese hira-kana "A" in EUC-JP
854853
* s.getch # => nil
855854
*/
856855
static VALUE
@@ -885,10 +884,9 @@ strscan_getch(VALUE self)
885884
* s.get_byte # => "b"
886885
* s.get_byte # => nil
887886
*
888-
* $KCODE = 'EUC'
889-
* s = StringScanner.new("\244\242")
890-
* s.get_byte # => "\244"
891-
* s.get_byte # => "\242"
887+
* s = StringScanner.new("\244\242".force_encoding("euc-jp"))
888+
* s.get_byte # => "\xA4"
889+
* s.get_byte # => "\xA2"
892890
* s.get_byte # => nil
893891
*/
894892
static VALUE

0 commit comments

Comments
 (0)