3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Curlでレスポンス文字列をUnicodeからUTF-8に変える。

Posted at

よく忘れるのでメモ。
レスポンスが以下のような文字列で帰ってこられても困る…。

\u30b7\u30b9\u30c6\u30e0\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\n\u7533\u3057\u8a33\u3054\u3056\u3044\u307e\u305b\u3093\u304c\u3001\u6642\u9593\u3092\u304a\u3044\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002

Perlが使える環境なら以下をつけてあげるといい感じになる、。
perl -Xpne 's/\\u([0-9a-fA-F]{4})/chr(hex($1))/eg'

curl localhost:8080/api/path | perl -Xpne 's/\\u([0-9a-fA-F]{4})/chr(hex($1))/eg'
"システムエラーが発生しました。\n申し訳ございませんが、時間をおいてから再度お試しください。"

こんなメモでも、誰かの役に立てばいいなあ。

3
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?