From: "U.NAKAMURA" <usa@garbagecollect.jp>
To: "Ruby developers \(Japanese\)" <ruby-dev@ruby-lang.org>
Subject: [ruby-dev:51013] Re: 2.7までで動いていたが3.0でエンコードのエラーになる
Date: Thu, 04 Feb 2021 01:18:04 +0900 [thread overview]
Message-ID: <20210204011804.308E.C613B076@garbagecollect.jp> (raw)
In-Reply-To: <CAAVV8PfurXGpp5ZgHfG5JOMC=CqW3o4T7JW6hG6HEN8xTsCu3A@mail.gmail.com>
こんにちは、なかむら(う)です。
In message "[ruby-dev:51012] Re: 2.7までで動いていたが3.0でエンコードのエラーになる"
on Thu, 4 Feb 2021 00:01:00 +0900, paptimusx@gmail.com wrote:
> 2行目に
> coding: cp932
> があり、これは効いているはずです。
それはソースのエンコーディングの指定です。
言い換えると、コード中の文字列や正規表現のリテラルのエンコーディングを指定しているだけであり、外部エンコーディングには影響はありません。
> > > fin = open(file, 'r')
> >
> > ここで encoding: 'cp932' あたりを指定してください
ですので、ファイルをオープンする際に、そのファイルのエンコーディングを
fin = open(file, 'r', encoding: 'cp932')
などといった方法で指定してください。
それでは。
--
U.Nakamaura <usa@garbagecollect.jp>
next prev parent reply other threads:[~2021-02-03 16:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 14:28 [ruby-dev:51000] 2.7までで動いていたが3.0でエンコードのエラーになる paptimusx
2021-01-29 15:05 ` [ruby-dev:51001] 2.7までで動いていたが3.0でエンコードのエラーになる U.NAKAMURA
2021-02-03 15:01 ` [ruby-dev:51012] " paptimusx
2021-02-03 16:18 ` U.NAKAMURA [this message]
2021-02-03 16:43 ` [ruby-dev:51014] " paptimusx
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210204011804.308E.C613B076@garbagecollect.jp \
--to=usa@garbagecollect.jp \
--cc=ruby-dev@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).