1 28 29 package com.caucho.vfs.i18n; 30 31 import java.io.IOException ; 32 import java.io.InputStream ; 33 import java.io.Reader ; 34 35 49 public class WindowsHackReader extends EncodingReader { 50 private InputStream is; 51 52 55 public WindowsHackReader() 56 { 57 } 58 59 62 private WindowsHackReader(InputStream is) 63 { 64 this.is = is; 65 } 66 67 75 public Reader create(InputStream is, String javaEncoding) 76 { 77 return new WindowsHackReader(is); 78 } 79 80 83 public int read() 84 throws IOException 85 { 86 int ch1 = is.read(); 87 88 switch (ch1) { 89 case 130: return ','; 91 92 case 131: return 'f'; 94 95 case 132: return '"'; 97 98 case 133: return 8230; 100 101 case 134: return '+'; 103 104 case 135: return '+'; 106 107 case 136: return '^'; 109 110 case 137: return 8240; 112 113 case 138: return 'S'; 115 116 case 139: return '<'; 118 119 case 140: return 'O'; 121 122 case 145: case 146: return '\''; 125 126 case 147: case 148: return '"'; 129 130 case 149: return '*'; 132 133 case 150: case 151: return '-'; 136 137 case 152: return '~'; 139 140 case 153: return 8482; 142 143 case 154: return 's'; 145 146 case 155: return '>'; 148 149 case 156: return 'o'; 151 152 case 376: return 'Y'; 154 155 default: 156 return ch1; 157 } 158 } 159 160 169 public int read(char []cbuf, int off, int len) 170 throws IOException 171 { 172 int i = 0; 173 174 for (i = 0; i < len; i++) { 175 int ch = is.read(); 176 177 if (ch < 0) 178 return i == 0 ? -1 : i; 179 180 switch (ch) { 181 case -1: 182 return i == 0 ? -1 : i; 183 184 case 130: cbuf[off + i] = ','; 186 break; 187 188 case 131: cbuf[off + i] = 'f'; 190 break; 191 192 case 132: cbuf[off + i] = '"'; 194 break; 195 196 case 133: cbuf[off + i] = (char) 8230; 198 break; 199 200 case 134: cbuf[off + i] = '+'; 202 break; 203 204 case 135: cbuf[off + i] = '+'; 206 break; 207 208 case 136: cbuf[off + i] = '^'; 210 break; 211 212 case 137: cbuf[off + i] = (char) 8240; 214 break; 215 216 case 138: cbuf[off + i] = 'S'; 218 break; 219 220 case 139: cbuf[off + i] = '<'; 222 break; 223 224 case 140: cbuf[off + i] = 'O'; 226 break; 227 228 case 145: case 146: cbuf[off + i] = '\''; 231 break; 232 233 case 147: case 148: cbuf[off + i] = (char) '"'; 236 break; 237 238 case 149: cbuf[off + i] = (char) '*'; 240 break; 241 242 case 150: case 151: cbuf[off + i] = (char) '-'; 245 break; 246 247 case 152: cbuf[off + i] = (char) '~'; 249 break; 250 251 case 153: cbuf[off + i] = (char) 8482; 253 break; 254 255 case 154: cbuf[off + i] = 's'; 257 break; 258 259 case 155: cbuf[off + i] = '>'; 261 break; 262 263 case 156: cbuf[off + i] = 'o'; 265 break; 266 267 case 376: cbuf[off + i] = 'Y'; 269 break; 270 271 default: 272 cbuf[off + i] = (char) ch; 273 } 274 } 275 276 return i; 277 } 278 } 279 | Popular Tags |