{"type":"rich","version":"1.0","blog_title":"\u52d5\u304b\u3056\u308b\u3053\u3068\u30d0\u30b0\u306e\u5982\u3057","author_url":"https://blog.hatena.ne.jp/thr3a/","blog_url":"https://blog.turai.work/","title":"Ruby\u3067UTF-8\u3092ShiftJIS\u306b\u5909\u63db\u3059\u308b\u306a\u3089nkf\u3092\u4f7f\u3046\u3079\u304d","categories":["ruby"],"width":"100%","image_url":null,"published":"2018-07-19 10:44:15","provider_url":"https://hatena.blog","url":"https://blog.turai.work/entry/20180719/1531964655","description":"Windows\u3068\u304b\u3044\u3046\u30b4\u30dfOS\u3092\u8003\u616e\u3059\u308b\u305b\u3044\u3067\u3001\u3082\u3046\u3059\u3050\u6771\u4eac\u30aa\u30ea\u30f3\u30d4\u30c3\u30af\u958b\u50ac\u306e2020\u5e74\u306b\u8fd1\u3065\u3044\u305f\u3068\u3044\u3046\u306e\u306bShiftJIS\u3067\u51fa\u529b\u3057\u305f\u3044\u30b1\u30fc\u30b9\u304c\u3042\u308b\u3002 .encode()\u4f7f\u3048\u3070\u3044\u3044\u3093\u3067\u3057\u3087\uff1f Ruby\u306f\u3082\u3068\u3082\u3068UTF-8\u306a\u306e\u3067UTF-8\u2192ShiftJIS\u306e\u5909\u63db\u306b\u306a\u308astr.encode(Encoding::Windows_31J)\u3067\u3044\u3051\u308b\u3002\u8a33\u304c\u306a\u304b\u3063\u305f irb(main):001:0> str = \"\u301c\u938c\u5009\u5e55\u5e9c\u301c\" => \"\u301c\u938c\u5009\u5e55\u5e9c\u301c\" irb(main):003:0> str2 = str.encode(Encoding::Windows_31J, undef: :replace).enc\u2026","provider_name":"Hatena Blog","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.turai.work%2Fentry%2F20180719%2F1531964655\" title=\"Ruby\u3067UTF-8\u3092ShiftJIS\u306b\u5909\u63db\u3059\u308b\u306a\u3089nkf\u3092\u4f7f\u3046\u3079\u304d - \u52d5\u304b\u3056\u308b\u3053\u3068\u30d0\u30b0\u306e\u5982\u3057\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","author_name":"thr3a","height":"190"}