question: private static boolean isASCIISuperset ( String encoding ) throws Exception { String chkS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz-_.!~*'();/?:@&=+$," ; byte [ ] chkB = { 48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 97 , 98 , 99 , 100 , 101 , 102 , 103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116 , 117 , 118 , 119 , 120 , 121 , 122 , 45 , 95 , 46 , 33 , 126 , 42 , 39 , 40 , 41 , 59 , 47 , 63 , 58 , 64 , 38 , 61 , 43 , 36 , 44 } ; byte [ ] b = chkS . getBytes ( encoding ) ; return Arrays . equals ( b , chkB ) ; }
target:  Test the named character encoding to verify that it converts ASCII characters correctly. We have to use an ASCII based encoding, or else the NetworkClients will not work correctly in EBCDIC based systems. However, we cannot just use ASCII or ISO8859_1 universally, because in Asian locales, non-ASCII characters may be embedded in otherwise ASCII based protocols (eg. HTTP). The specifications (RFC2616, 2398) are a little ambiguous in this matter. For instance, RFC2398 [part 2.1] says that the HTTP request URI should be escaped using a defined mechanism, but there is no way to specify in the escaped string what the original character set is. It is not correct to assume that UTF-8 is always used (as in URLs in HTML 4.0).  For this reason, until the specifications are updated to deal with this issue more comprehensively, and more importantly, HTTP servers are known to support these mechanisms, we will maintain the current behavior where it is possible to send non-ASCII characters in their original unescaped form.