Forums: 公開討議 (Thread #26110)

全角円マークが半角に変換されてしまう (2010-04-24 14:02 by Anonymous #50251)

以下のように実行した場合などに全角円マークが半角円マークに変換されてしまいます。
echo "¥" | nkf -w
全角を保持したい場合にはどうすればいいのでしょうか?
nkfのバージョンはCentOS5のnkf-2.07-1.1.fc6と2.1.0で試してみましたが同様の結果でした。

よろしくお願いします。

Reply to #50251×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 全角円マークが半角に変換されてしまう (2010-04-24 16:34 by naruse #50253)

Unicode to Unicode の変換でも一度内部で正規化しているからですね。

以下の通りにすれば正規化しないようになります。
echo "¥" | nkf -w --no-best-fit-chars
Reply to #50251

Reply to #50253×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 全角円マークが半角に変換されてしまう (2010-04-24 18:20 by Anonymous #50254)

ありがとうございます。

ご指摘のオプションで全角円マークが保持されることが確認できました。
Reply to #50253

Reply to #50254×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login