{"id":544,"date":"2008-05-14T01:46:22","date_gmt":"2008-05-13T16:46:22","guid":{"rendered":"http:\/\/hanury.net\/wp\/archives\/544"},"modified":"2024-08-29T20:34:22","modified_gmt":"2024-08-29T11:34:22","slug":"ruby-%ea%b0%80%ed%9e%a3eachx-print-x","status":"publish","type":"post","link":"https:\/\/hanury.net\/wp\/archives\/544","title":{"rendered":"[ruby] (&#8216;\uac00&#8217;..&#8217;\ud7a3&#8217;).each{|x| print x}"},"content":{"rendered":"<p>\ub8e8\ube44 \uacf5\ubd80 \uc2dc\uc791\ud55c\uc9c0 \ub2e4\uc74c\ub0a0 \ubb38\ub4dd\nUnicode\uc758 \ud55c\uae00 \uc601\uc5ed\uc744 \uc804\ubd80 \ucd9c\ub825\ud558\ub294 \ud504\ub85c\uadf8\ub7a8\uc744 ruby\ub85c \uc9dc\uba74 \uc5b4\ub5bb\uac8c \ub420\uae4c \uad81\uae08\ud574 \uc84c\ub2e4.<\/p>\n<p>\uba38\ub9ac \uc18d\uc5d0\uc11c\ub294 \uc9c1\uad00\uc801\uc73c\ub85c <\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\n('\uac00'..'\ud7a3').each{|x| print x}\n<\/pre>\n<p>\ub780 \ucf54\ub4dc\uac00 \ub5a0 \uc62c\ub790\ub2e4. \uac81\ub098 \uba4b\uc9c0\ub2e4.\n&#8216;\uac00&#8217;\uc758 Unicode\uac00 AC00\uc778\uc9c0 \ubaa8\ub974\ub354\ub77c\ub3c4 (&#8216;\ud7a3&#8217;\uc758 \ucf54\ub4dc \uac12\uc740 \uc678\uc6b0\uace0 \uc788\uc9c0\ub3c4 \uc54a\ub2e4.) Range\uac00 \uc9c0\uc6d0\ud574\uc8fc\uc9c0 \uc54a\uc744\uae4c?<\/p>\n<p>\ub2e4\ub978 \uc5b8\uc5b4\ub77c\uba74 \ubd84\uba85 \ub8e8\ud504\uac00 \ube59\ube59 \ub3cc\uace0,\n&#8216;\uac00&#8217;\uac00 \uc544\ub2cc AC00\ubd80\ud130 code\uac12\uc744 \uc99d\uac00\uc2dc\ud0a4\uba74\uc11c&#8230;. \uc5b4\uca4c\uad6c \uc800\uca4c\uad6c \ud558\ub294 \ucf54\ub4dc\uac00 \ub420\ud130\uc778\ub370&#8230;.<\/p>\n<p>\uadfc\ub370 \uc548\ub3c8\ub2e4.\n\ub354 \uc815\ud655\ud788\ub294 \ub3c4\ub294\ub4ef \ud558\ub2e4 \ub9cc\ub2e4.<\/p>\n<p>\uc774\uc720\ub294 ruby String\uc758 \ub0b4\ubd80\ucc98\ub9ac\uac00 UTF-8\uc774\uc5b4\uc11c \uadf8\ub7ac\ub2e4.\n\uc774\ub7f0 \uc820\uc7a5&#8230;.<\/p>\n<p>UTF-8\ub3c4 Unicode \uc778\ucf54\ub529 \uae30\ubc95\uc911 \ud558\ub098 \ub9de\uace0, \ub098\ub984 \uc7a5\ub2e8\uc774 \uc788\ub294 \uc720\ub2c8\ucf54\ub4dc \uc778\ucf54\ub529\uc774\uc9c0\ub9cc,\n\uc9c1\ub82c\ud654\ub098, \ub124\ud2b8\uc6cd \uc804\uc1a1\uc2dc\uc5d0\ub098 \uc801\ud569\ud55c \uc778\ucf54\ub529\uc774\uace0, \uba54\ubaa8\ub9ac \ub0b4\ubd80 \ucc98\ub9ac\ub294 UCS2\ub098 \ud558\ub2e4 \ubabb\ud574 UCS4\ub85c \ucc98\ub9ac\ud568\uc774 \ub9de\ub2e4\uace0 \ubcf8\ub2e4.\n\uadf8\ub798\uc57c \uae30\uaecf Unicode\uc5d0\uc11c \uc695\uba39\uc5b4 \uac00\uba74\uc11c \ud604\ub300 \ud55c\uae00 11072\uc790 \ubaa8\ub450 \ud560\ub2f9 \ubc1b\uc544 \ud55c\uae00 \ucc98\ub9ac\uac00 \uc870\ud569\ud615\ucc98\ub7fc \ucc98\ub9ac\uac00 \uac00\ub2a5\ud558\uace0, \ud55c\uae00 \uc18c\ud305 \ubb38\uc81c\ub098&#8230;..\n\uae30\ud0c0\ub4f1\ub4f1&#8230;(\uc695\uae4c\uc9c4 \uc548\uba39\uc5c8\ub098? \ud558\uc9c0\ub9cc \ub208\uce58 \ubcf4\uba74\uc11c&#8230;)<\/p>\n<p>\uc544\ub9c8\ub3c4 ASCII\uac00 1byte\ub85c \uc778\ucf54\ub529\ub418\ub294 \uc810 \ub54c\ubb38\uc5d0 (\uc601\uc5b4\uad8c \ud504\ub85c\uadf8\ub798\uba38\uc758&#8230;)\ud798\uc5d0\uc11c \ubc00\ub9b0\ub4ef \ud558\ub2e4.<\/p>\n<p>\uc554\ud2bc String succ\uba54\uc18c\ub4dc\ub97c \uac74\ub4dc\ub9ac\uace0\uc57c \ub9d0\uc558\ub2e4.(\ubcc4 \ubc14\ub78c\uc9c1\ud574 \ubcf4\uc774\uc9c4 \uc54a\uc9c0\ub9cc&#8230;)<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\nclass String\n    def succ\n        head = self.unpack('U*')\n        tail = head.pop\n        return head.pack('U*') + [tail + 1].pack('U*')\n    end \nend\n\n(\"\uac00\"..\"\ud7a3\").each{|x| print x}\n(\"\u3042\"..\"\u3093\").each{|x| print x}\n\n#\"\uac00\ub098\ub2e4\".each_char {|x| print x}\nputs \"\uac00\ub098\ub2e4\".succ\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\uac00\uac01\uac02\uac03\uac04\uac05\uac06\uac07\uac08\uac09\uac0a\uac0b\uac0c\uac0d\uac0e\uac0f\uac10\uac11\uac12\uac13\uac14\uac15\uac16\uac17\uac18\uac19\uac1a\uac1b\uac1c\uac1d\uac1e\uac1f\uac20\uac21\uac22\uac23\uac24\uac25\uac26\uac27\uac28\uac29\uac2a\uac2b\uac2c\n\uac2d\uac2e\uac2f\uac30\uac31\uac32\uac33\uac34\uac35\uac36\uac37\uac38\uac39\uac3a\uac3b\uac3c\uac3d\uac3e\uac3f\uac40\uac41\uac42\uac43\uac44\uac45\uac46\uac47\uac48\uac49\uac4a\uac4b\uac4c\uac4d\uac4e\uac4f\uac50\uac51\uac52\uac53\uac54\uac55\uac56\uac57\uac58\uac59\n...\n\ud79f\ud7a0\ud7a1\ud7a2\ud7a3\u3042\u3043\u3044\u3045\u3046\u3047\u3048\u3049\u304a\u304b\u304c\u304d\u304e\u304f\u3050\u3051\u3052\u3053\u3054\u3055\u3056\u3057\u3058\u3059\u305a\u305b\u305c\u305d\u305e\u305f\u3060\u3061\u3062\u3063\u3064\u3065\u3066\u3067\u3068\u3069\n\u306a\u306b\u306c\u306d\u306e\u306f\u3070\u3071\u3072\u3073\u3074\u3075\u3076\u3077\u3078\u3079\u307a\u307b\u307c\u307d\u307e\u307f\u3080\u3081\u3082\u3083\u3084\u3085\u3086\u3087\u3088\u3089\u308a\u308b\u308c\u308d\u308e\u308f\u3090\u3091\u3092\u3093\uac00\ub098\ub2e5\n<\/pre>\n<p>\uac00\ub2a5\uc131\uc740 \ud76c\ubc15\ud558\uaca0\uc9c0\ub9cc, ruby 2.0\uc5d0\uc11c\ub294 \uc81c\ubc1c UCS2\ub098 4\ub85c String \ub0b4\ubd80\ucc98\ub9ac\uac00 \ubc14\ub00c\uc5c8\uc73c\uba74 \ud558\ub294 \ubc14\ub78c\uc774\ub2e4.<\/p>","protected":false},"excerpt":{"rendered":"<p>\ub8e8\ube44 \uacf5\ubd80 \uc2dc\uc791\ud55c\uc9c0 \ub2e4\uc74c\ub0a0 \ubb38\ub4dd Unicode\uc758 \ud55c\uae00 \uc601\uc5ed\uc744 \uc804\ubd80 \ucd9c\ub825\ud558\ub294 \ud504\ub85c\uadf8\ub7a8\uc744 ruby\ub85c \uc9dc\uba74 \uc5b4\ub5bb\uac8c \ub420\uae4c \uad81\uae08\ud574 \uc84c\ub2e4. \uba38\ub9ac \uc18d\uc5d0\uc11c\ub294 \uc9c1\uad00\uc801\uc73c\ub85c (&#8216;\uac00&#8217;..&#8217;\ud7a3&#8217;).each{|x| print x} \ub780 \ucf54\ub4dc\uac00 \ub5a0 \uc62c\ub790\ub2e4. \uac81\ub098 \uba4b\uc9c0\ub2e4. &#8216;\uac00&#8217;\uc758 [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[26,327,23],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-it","tag-ruby","tag-it","tag-23"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2lq6V-8M","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/comments?post=544"}],"version-history":[{"count":12,"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/posts\/544\/revisions"}],"predecessor-version":[{"id":5777,"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/posts\/544\/revisions\/5777"}],"wp:attachment":[{"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/media?parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/categories?post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hanury.net\/wp\/wp-json\/wp\/v2\/tags?post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}