{"id":566,"date":"2012-11-26T10:01:50","date_gmt":"2012-11-26T10:01:50","guid":{"rendered":"http:\/\/www.bardecode.com\/newsite\/?p=566"},"modified":"2013-03-01T15:28:23","modified_gmt":"2013-03-01T15:28:23","slug":"handling-unicode-encoded-barcodes-in-java","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/newsite\/handling-unicode-encoded-barcodes-in-java\/","title":{"rendered":"Handling unicode encoded barcodes in Java"},"content":{"rendered":"<p>2-D barcode formats such as PDF-417 can encode a huge character set, which means that the barcode reader toolkit needs to encode characters outside the normal ASCII range. If the Encoding property is set to 2 then the toolkit will use Unicode encoding, whereby characters can be represented by the string &amp;#N; where N is an integer.<\/p>\n<p>For example:<\/p>\n<p>&amp;#209; represents the character \u00d1<\/p>\n<p>The following Java function may be used to decode such a string:<\/p>\n<p>String decodeBarcodeString(String barcodeString) throws Exception{<br \/>\nString decodedString = &#8220;&#8221;;<br \/>\nString tempString = &#8220;&#8221;;<br \/>\nchar []array = barcodeString.toCharArray();<br \/>\nfor(int i=0; i&lt;array.length;i++){<br \/>\nif(array[i]==&#8217;&amp;&#8217;)i++;<br \/>\nif(array[i]==&#8217;#&#8217;){<br \/>\nint j = i;<br \/>\nint count = 0;<br \/>\nint value = 0;<br \/>\ntempString=&#8221;&#8221;;<br \/>\nwhile(array[++j]!=&#8217;;&#8217;){<br \/>\ncount++;<br \/>\ntempString+=array[j];<br \/>\n}<br \/>\ni+=(count+1);<br \/>\nvalue = Integer.parseInt(tempString);<br \/>\nif(value==0){<br \/>\ndecodedString+=&#8221; &#8220;;<br \/>\n}else {<\/p>\n<p>decodedString+=Character.toString((char)value);<br \/>\n}<br \/>\n}else{<br \/>\ndecodedString+=array[i];<br \/>\n}<br \/>\n}<br \/>\nreturn decodedString;<br \/>\n}<br \/>\nThe above function was kindly supplied by TigerIT Bangladesh Ltd\u00a0<a href=\"http:\/\/www.tigeritbd.com\/\">www.tigeritbd.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>2-D barcode formats such as PDF-417 can encode a huge character set, which means that the barcode reader toolkit needs to encode characters outside the normal ASCII range. If the Encoding property is set to 2 then the toolkit will use Unicode encoding, whereby characters can be represented by the string &amp;#N; where N is &hellip; <\/p>\n","protected":false},"author":1,"featured_media":334,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76,31],"tags":[74,86,19,56,103,104,72,69,65,48,83],"class_list":["post-566","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-settings","category-software-development-kits","tag-2d-barcode","tag-ascii","tag-barcode","tag-barcode-reader","tag-encode","tag-java","tag-pdf-417","tag-scanner","tag-sdk-2","tag-toolkit","tag-unicode"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts\/566"}],"collection":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/comments?post=566"}],"version-history":[{"count":3,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts\/566\/revisions"}],"predecessor-version":[{"id":568,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts\/566\/revisions\/568"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/media\/334"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/media?parent=566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/categories?post=566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/tags?post=566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}