You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shanta B <B....@siemens.com> on 2003/08/05 15:19:25 UTC
? problem
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 €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 € 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("<"); break;
case '>': sb.append(">"); break;
case '&': sb.append("&"); break;
case '"': sb.append("""); break;
case 'ä': sb.append("ä"); break;
case 'ö': sb.append("ö"); break;
case 'ü': sb.append("ü"); break;
case 'ß': sb.append("ß"); break;
case 'Ä': sb.append("Ä"); break;
case 'Ö': sb.append("Ö"); break;
case 'Ü': sb.append("Ü"); break;
case '§': sb.append("§"); break;
case 'EUR': sb.append("€"); 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("€","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 € in place of EUR