Project

General

Profile

Actions

Bug #3179

closed

getc with text mode returns ASCII-8BIT

Added by mame (Yusuke Endoh) about 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2010-04-20 trunk 27405) [i686-linux]
Backport:
[ruby-dev:41023]

Description

=begin
遠藤です。

以下の動作は意図的でしょうか。

coding: UTF-8

"あいう" というファイルを作る

s = "あいう"
open("foo.txt", "wb") {|f| f.write(s) }

IO#read で一気に読めば期待通り

open("foo.txt", "rt") {|f| p f.read } #=> "あいう"

getc するとバイナリとして読んだ感じになる

open("foo.txt", "rt") do |f|
p f.getc #=> "\xE3"
p f.getc #=> "\x81"
p f.getc #=> "\x82"
end

各 getc で "あ" "い" "う" が帰ってくることを期待しました。
LANG は ja_JP.UTF-8 です。

--
Yusuke Endoh
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0