LoginSignup
0
0

More than 5 years have passed since last update.

nkf の代替としての StreamRelay.NET.exe (文字コード変換)

Last updated at Posted at 2017-05-26

StreamにReader/Writerを被せる事で、(文字コードを含む)文字列を扱うことができるので、入力の文字コードと出力の文字コードを異なるオプション指定をすれば、文字コード変換を行う事ができる

オプション

使うオプションは、

全体設定は・・・

通信方向ごとに個別に設定したい場合は↓

  • -InputRequestCharset
  • -OutputRequestCharset
  • -InputResponseCharset
  • -OutputResponseCharset

レスポンスだけ文字コード変換したい。という時に使える

文字コード変換ツールとしての StreamRelay.jar

ShiftJISからEUC-JPへの変換

nkf.exe -S -e input.txt > output.txt

StreamRelay.NET.exe -LocalPort 0 -LocalInputFile a.txt -InputRequestCharset Shift_JIS -RemotePort 0 -OutputRequestCharset EUC-JP -RemoteOutputFile output.txt

文字コード一覧のオプション

`StreamRelay.NET.exe -ListCharset

改行コードの変換もできるよ

netstreamスキームの以下のオプションで、改行コードの変換もできるよ

Streamのread中に変換を行う
- inputLf (CrLf→Lf)
- inputCrLf (Lf→CrLf)

Streamのwrite中に変換を行う
- outputLf (CrLf→Lf)
- outputCrLf (Lf→CrLf)

例えば
-LocalProxy netstream:///?inputCrLf
というオプションにすれば、「ローカル」と呼称する側の入力時に「Lf→CrLf」という変換処理を実施する
ということになる


目次へ戻る

目次というか最初の一歩

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0