{"id":4631,"date":"2014-03-30T14:04:49","date_gmt":"2014-03-30T14:04:49","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/utf-8-to-ebcdic-in-java-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:04:49","modified_gmt":"2014-03-30T14:04:49","slug":"utf-8-to-ebcdic-in-java-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/utf-8-to-ebcdic-in-java-collection-of-common-programming-errors\/","title":{"rendered":"UTF-8 to EBCDIC in Java-Collection of common programming errors"},"content":{"rendered":"<p>Assuming your target system is an IBM mainframe or midrange, it has full support for all of the EBCDIC encodings built into it&#8217;s JVM as encodings named CPxxxx, corresponding to the IBM CCSID&#8217;s (CP stands for code-page). You will need to do the translations on the host-side since the client side will not have the necessary encoding support.<\/p>\n<p>Since Unicode is DBCS and greater, and supports every known character, you will likely be targeting multiple EBCDIC encodings; so you will likely configure those encodings in some way. Try to have your client Unicode (UTF-8, UTF-16, etc) only, with the translations being done as data arrives on the host and\/or leaves the host system.<\/p>\n<p>Other than needing to do translations host-side, the mechanics are the same as any Java translation; e.g. new String(bytes,encoding) and String.getBytes(encoding), and the various NIO and writer classes. There&#8217;s really no magic &#8211; it&#8217;s no different than translating between, say, ISO 8859-x and Unicode, or any other SBCS (or limited DBCS).<\/p>\n<p>For example:<\/p>\n<pre><code>byte[] ebcdta=\"Hello World\".getBytes(\"CP037\");  \/\/ get bytes for EBCDIC codepage 37\n<\/code><\/pre>\n<p>You can find more information on IBM&#8217;s documentation website.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Assuming your target system is an IBM mainframe or midrange, it has full support for all of the EBCDIC encodings built into it&#8217;s JVM as encodings named CPxxxx, corresponding to the IBM CCSID&#8217;s (CP stands for code-page). You will need to do the translations on the host-side since the client side will not have the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4631","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4631"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4631\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}