1 30 31 package org.jboss.axis.components.encoding; 32 33 34 41 42 class UTF8Encoder extends AbstractXMLEncoder 43 { 44 45 public String getEncoding() 46 { 47 48 return XMLEncoderFactory.ENCODING_UTF_8; 49 50 } 51 52 53 public boolean needsEncoding(char c) 54 { 55 56 return c > 0x7F; 57 58 } 59 60 61 public void appendEncoded(EncodedByteArray out, char c) 62 { 63 64 if (c < 0x80) 65 { 66 67 out.append(c); 68 69 } 70 else if (c < 0x800) 71 { 72 73 out.append((0xC0 | c >> 6)); 74 75 out.append((0x80 | c & 0x3F)); 76 77 } 78 else if (c < 0x10000) 79 { 80 81 out.append((0xE0 | c >> 12)); 82 83 out.append((0x80 | c >> 6 & 0x3F)); 84 85 out.append((0x80 | c & 0x3F)); 86 87 } 88 else if (c < 0x200000) 89 { 90 91 out.append((0xF0 | c >> 18)); 92 93 out.append((0x80 | c >> 12 & 0x3F)); 94 95 out.append((0x80 | c >> 6 & 0x3F)); 96 97 out.append((0x80 | c & 0x3F)); 98 99 } 100 101 } 102 103 } 104 105 | Popular Tags |