tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shanta B <B.Sha...@siemens.com>
Subject ? problem
Date Tue, 05 Aug 2003 13:19:25 GMT
Hi
     I need ur help ...In our application while creating a task we are
entering taskid,now we are getting some problem when we include EUR symbol
in taskid ..it will replace EUR symbol to &#8364;and it storing in database
also like this ,because of this when user enter 5 EUR symbols it will makes
database problem(taskid length is 16 in db,where as because of these EUR it
will place 5*7=35 characters in db).

I tried with following character sets ISO-8859-1,ISO-8859-15 and also UTF-8.

I have done the following things because of this i am able to display EUR in
gui(character set iso-8859-1) but still i am seeing &#8364; in database.


TaskDisp calls this method(HtsimpleDisp)
-----------------------------------------

public Input makeTextInputField(String name, int size, int maxlen, String
value)
{
    Input f =null;

    if(value != null)
        f =
makeInputType(Input.TEXT,name,Util.getEscapedString(value)/*escapeHTML(value
)*/);
    else
        f = makeInputType(Input.TEXT,name,value);

    f.setSize(size);
    f.setMaxlength(maxlen);
    return f;
}

this calls siefleet.util.Util package


public static String getEscapedString(String source)
{
          System.err.println("In getEscapedString "+source);
          StringBuffer result = new StringBuffer();
          for(int i=0; i<source.length(); i++)
          {
              char c = source.charAt(i);
              if(((int)c) < 256){ System.err.println("<<<<<<< 256
"+c);result.append(c);}
              else result.append("&#" + Integer.toString((int)c) + ";");
          }
          return result.toString();
}
 
              OR

public static String escapeHTML(String s)
{
       
        int l = s.length();
        StringBuffer sb = new StringBuffer();
        char[] val = s.toCharArray();
        int i;
        char c;
        for (i = 0; i < l; i++)
        {
            
            switch (c = val[i])
            {

                case '\n':      sb.append("<br/>"); break;
                case '<':       sb.append("&lt;"); break;
                case '>':       sb.append("&gt;"); break;
                case '&':       sb.append("&amp;"); break;
                case '"':       sb.append("&quot;"); break;
                case 'ä':       sb.append("&auml;"); break;
                case 'ö':       sb.append("&ouml;"); break;
                case 'ü':       sb.append("&uuml;"); break;
                case 'ß':       sb.append("&szlig;"); break;
                case 'Ä':       sb.append("&Auml;"); break;
                case 'Ö':       sb.append("&Ouml;"); break;
                case 'Ü':       sb.append("&Uuml;"); break;
                case '§':       sb.append("&sect;"); break;
                case 'EUR':       sb.append("&euro;"); break; //this is euro
entity value 

                default:
                    if (c < 32 || 129 < c)
                        sb.append("&#" + (int)c + ";");
                    else
                        sb.append(c);
            }
        }
        return sb.toString();
    }


Where as in EditTask we are calling Map taskAttrs =
dumTask.makeTableFromHttpRequest(s,req); this will call
common/store/JavaConverter.java

public static String toStringClass(Object o)
{
     if (o == null)
        return null;
     if (o instanceof String)
     {

       System.err.println("In Javaconverter o is string
"+System.getProperty("file.encoding"));
       String  myval=(String)o;
       myval=Util.getEscapedString(myval);
       System.err.println("In Javaconverter o is string "+myval);
       return myval;

        /*System.setProperty("file.encoding","ISO-8859-1");
        System.err.println("In Javaconverter o is string
"+System.getProperty("file.encoding"));
        //return (String)o;

        String  myval=(String)o;
        System.err.println("In Javaconverter o is string "+myval);
        myval=myval.replaceAll("&#8364;","EUR");
        myval=Util.escapeHTML(myval);
        System.err.println("In Javaconverter o is string after parsing
"+myval);
        return myval;*/
        //return (String)o;
     }
     return o.toString();
}

My quetion why database storing &#8364; in place of EUR

Mime
View raw message