00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 package org.mpcl.text.html;
00028
00029 import java.text.StringCharacterIterator;
00030
00031
00032 public class TEntity
00033 {
00034
00035 public static String _encodeCharacters (String ySOURCE)
00036 {
00037
00038 StringCharacterIterator I;
00039 StringBuffer yEncodedSource = null;
00040
00041 if ( ySOURCE != null )
00042 {
00043 I = new StringCharacterIterator (ySOURCE);
00044 yEncodedSource = new StringBuffer();
00045 for (char cSOURCE = I.first(); ( cSOURCE != StringCharacterIterator.DONE ) ;cSOURCE = I.next())
00046 {
00047 switch (cSOURCE)
00048 {
00049 case '<' : yEncodedSource.append ("<"); break;
00050 case '>' : yEncodedSource.append (">"); break;
00051 case '\u00e1' : yEncodedSource.append ("á"); break;
00052 case '\u00e9' : yEncodedSource.append ("é"); break;
00053 case '\u00ed' : yEncodedSource.append ("í"); break;
00054 case '\u00f3' : yEncodedSource.append ("ó"); break;
00055 case '\u00fa' : yEncodedSource.append ("ú"); break;
00056 case '\u00c1' : yEncodedSource.append ("Á"); break;
00057 case '\u00c9' : yEncodedSource.append ("É"); break;
00058 case '\u00cd' : yEncodedSource.append ("Í"); break;
00059 case '\u00d3' : yEncodedSource.append ("Ó"); break;
00060 case '\u00da' : yEncodedSource.append ("Ú"); break;
00061 case '"' : yEncodedSource.append ("""); break;
00062 case '\'': yEncodedSource.append ("'"); break;
00063 case '&' : yEncodedSource.append ("&"); break;
00064 case '\u00f1': yEncodedSource.append ("ñ"); break;
00065 case '\u00d1' : yEncodedSource.append ("Ñ"); break;
00066 default: yEncodedSource.append (cSOURCE); break;
00067 }
00068 }
00069 }
00070 return yEncodedSource.toString();
00071
00072 }
00073
00074 }