{"id":69,"date":"2010-11-09T22:13:58","date_gmt":"2010-11-10T02:13:58","guid":{"rendered":"http:\/\/galencharlton.com\/blog\/?p=69"},"modified":"2010-11-09T22:13:58","modified_gmt":"2010-11-10T02:13:58","slug":"a-pragma-that-does-less-than-you-might-think","status":"publish","type":"post","link":"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/","title":{"rendered":"A pragma that does less than you might think"},"content":{"rendered":"<p>I noticed that  a patch recently submitted for Koha adds the following line to one of Koha&#8217;s Perl modules:<br \/>\n<code><br \/>\nuse utf8;<br \/>\n<\/code><br \/>\n<code>utf8<\/code> is a perfectly fine and proper Perl pragma, right?  Indeed it is.  The problem is that the purpose of the patch is to try to fix an issue with reading and displaying UTF-8 characters from a file.  So what does <code>use utf8;<\/code> contribute to that patch?<\/p>\n<p>Nothing.<\/p>\n<p>The <em>only<\/em> thing that the <code><a href=\"http:\/\/perldoc.perl.org\/utf8.html\">utf8<\/a><\/code> pragma does is signal to the Perl interpreter that the Perl source code is in UTF-8.  If you&#8217;re using non-ASCII characters in your source code, you&#8217;ll need the pragma.  For example,<br \/>\n<code><br \/>\nuse utf8;<br \/>\nmy $str = \"La lluvia en Espa\u00f1a se mantiene principalmente en el llano!\";<br \/>\n<\/code><br \/>\nor even<br \/>\n<code><br \/>\nuse utf8;<br \/>\nmy $str_en_ingl\u00e9s = \"The rain in Spain falls mostly on the plain!\";<br \/>\n<\/code><br \/>\nIf what you&#8217;re actually trying to do is ensure that the script is handling UTF-8 input and output correctly, <code>use utf8;<\/code> won&#8217;t help.  This <a href=\"http:\/\/perldoc.perl.org\/perlunitut.html\">tutorial<\/a> will.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-69\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>More<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\"><span>Tumblr<\/span><\/a><\/li><li class=\"share-reddit\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-reddit sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/?share=reddit\" target=\"_blank\" title=\"Click to share on Reddit\"><span>Reddit<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>I noticed that a patch recently submitted for Koha adds the following line to one of Koha&#8217;s Perl modules: use utf8; utf8 is a perfectly&#8230;<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-69\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>More<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\"><span>Tumblr<\/span><\/a><\/li><li class=\"share-reddit\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-reddit sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/?share=reddit\" target=\"_blank\" title=\"Click to share on Reddit\"><span>Reddit<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2010\/11\/a-pragma-that-does-less-than-you-might-think\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[10,13,11],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3gJ9y-17","_links":{"self":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/69"}],"collection":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":10,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":79,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/69\/revisions\/79"}],"wp:attachment":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}