1 28 29 package com.caucho.xml; 30 31 import java.io.IOException ; 32 33 class XmlLatin1Entities extends XmlEntities { 34 private static Entities xmlEntities = new XmlLatin1Entities(); 35 36 static Entities create() 37 { 38 return xmlEntities; 39 } 40 41 void printText(XmlPrinter os, 42 char []text, int offset, int length, 43 boolean attr) 44 throws IOException 45 { 46 for (int i = 0; i < length; i++) { 47 char ch = text[offset + i]; 48 49 switch (ch) { 50 case '\t': 51 os.print(ch); break; 52 53 case '\n': 54 case '\r': 55 if (! attr) 56 os.print(ch); 57 else { 58 os.print("&#"); 59 os.print((int) ch); 60 os.print(";"); 61 } 62 break; 63 64 72 73 case '<': 74 os.print("<"); 75 break; 76 77 case '>': 78 os.print(">"); 79 break; 80 81 case '&': 82 os.print("&"); 83 break; 84 85 case '"': 86 if (attr) 87 os.print("""); 88 else 89 os.print('"'); 90 break; 91 92 default: 93 if (ch >= 0x20 && ch < 0x7f || ch > 160 && ch < 255) { 94 os.print(ch); 95 } 96 else { 97 os.print("&#"); 98 os.print((int) ch); 99 os.print(';'); 100 } 101 } 102 } 103 } 104 } 105 | Popular Tags |