struts 1.x /mysql stored function ...input string..charset latin1

2007-05-20 Thread john lee
In my Struts Action class,  I invoke mysql¡¯ stored function, but get following 
error:
   
  javax.servlet.ServletException: For input string: ¡°20) CHARSET latin1
  READS SQL DATA 
  ¡­
  java.lang.NumberFormatException: For input string: ¡°20) CHARSET latin1
   
 
  Source code:
  ¡­
  Struts Action.class
  ¡­
  String result;
  Connection con;
  CallableStatement mf=con.prepareCall(¡°{?call sf_login_check(?)}¡±);
  mf.registerOutParameter(1,TypesVARCHAR);
  mf.setString(2,¡±test¡±);
  mf.execute();
  result=mf.getString(1);
  ¡­
   
  Mysql stored function
  Create function sf_login_check(v_login_id varchar(10))
   returns varchar(20) READS SQL DATA
  BEGIN;
 DECLARE t_exist INT;
 Select cout(*) into t_exist from accts
  Where id=v_loginid;
  If t_exist1 then
  Return(¡®Success¡¯);
  Else
  Return(¡®Fail¡¯);
  End if;
  END;
   
  Any clue? Tks in advance
   
  john

   
-
Building a website is a piece of cake. 
Yahoo! Small Business gives you all the tools to get online.

Re: UTF-8 charset issue

2007-05-04 Thread piloupy GOTTAPIL

What I've done is stupid. I don't use the possibilities of the UTF-8
encoding by setting the charSet to ISO-8859-15.

It's been nearly 2 days that I'm on a detail according to my manager.
I'm obliged to put the UTF-8 aside...

To answer you :
- The JSP directive %@ page contentType=text/html;
charset=ISO-8859-15 % will replace the meta tag in the header to
specify the content type  charset.

- I can't use a struts.properties since it's a functionnality for
struts2. I'm working with Struts 1.3.

Thank you anyway for your answers, guys.

piloupy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: UTF-8 charset issue

2007-05-04 Thread jalal udeen

hi  all

I have to use pagination in jsp  so i did it with logic:iterate  tag as
follows but when i use  2 links   next and previous

but next link is not disspearinng when it reaces the last one can any help
me for this

the code follows


%
 String strOffset =0;
   if(request.getParameter(pagination)!=null)
strOffset=request.getParameter(pagination);
else
   strOffset =0;
   String strLength = 2;
   int increment = Integer.parseInt(strOffset) + Integer.parseInt(strLength)
;
   String strIncOffset = String.valueOf(increment);
 ArrayList list  =(ArrayList)request.getAttribute(pattern);
int size= list.size();

   if((Integer.parseInt(strIncOffset)= size))
strIncOffset =0;

%

*Logic tags*

logic:iterate id=user name=pattern scope=request type=
com.pa.pattern.helper.Helper offset=%=strOffset%
length=%=strLength%

* Links*



*Next Link:*

**



/tr
%


if(Integer.parseInt(strOffset)!=size   !((Integer.parseInt(strOffset)size)
)  !(Integer.parseInt(strLength)=size) )

{


%
table align=right
TRTD ALIGN=a href=viewpattern.do?pagination=%=strIncOffset%

Next/a/TD

%
}

%





*prev Link*

**

%


if((strIncOffset.trim().equals(String.valueOf(size)) ||
Integer.parseInt(strOffset)

0   )  !(Integer.parseInt(strLength)=size))

{
strIncOffset=String.valueOf(Integer.parseInt(strOffset)-2);

%

TDa href=viewpattern.do?pagination=%=strIncOffset%

Prev/a/td/tr

%
}%



pls i need a help for this



thanks

jalaludeen


Re: UTF-8 charset issue

2007-05-04 Thread Laurie Harper

piloupy GOTTAPIL wrote:

What I've done is stupid. I don't use the possibilities of the UTF-8
encoding by setting the charSet to ISO-8859-15.

It's been nearly 2 days that I'm on a detail according to my manager.
I'm obliged to put the UTF-8 aside...

To answer you :
- The JSP directive %@ page contentType=text/html;
charset=ISO-8859-15 % will replace the meta tag in the header to
specify the content type  charset.


I would recommend using both; the @page directive tells the JSP 
processor to output ISO-8859-15 (or whatever you specify), while the 
META tag tells the browser to interpret the page using that encoding. 
You need both to be in sync, obviously. That should take care of output 
data.


The browser will then, by convention, encode any request data it sends 
in the same encoding as the page you delivered, at which point you need 
to be sure to use the correct encoding to read the parameters. To do 
that, you need to call the request.setCharacterEncoding() method. The 
easiest way to make sure that happens before the request data is read is 
to use a Servlet Filter. If you don't set the request encoding, input 
data may/will appear 'corrupted'.


Most importantly, *be consistent*. You *must* specify the same character 
encoding everywhere so everything stays in sync. Finally, I'd suggest 
using UTF-8 from the get-go, so you don't run into limitations on what 
you can display or read down the line.


HTH,

L.


- I can't use a struts.properties since it's a functionnality for
struts2. I'm working with Struts 1.3.

Thank you anyway for your answers, guys.

piloupy



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



UTF-8 charset issue

2007-05-03 Thread piloupy GOTTAPIL

Hello,

I have a website using :

- Struts 1.3
- Hibernate 3.2
- Tomcat 5.5
- Java 1.5.0
- MySQL 4.1.22

All my site and my database are encoded in UTF-8.

When I enter in a form the character e-accute, it becomes an 'A' with
a tild, following by a (c) (copyright character). I've made several
tests to find where the problem is.

In the Struts Action which handles the form, I've put this code :

System.out.println(Default Charset :  + Charset.defaultCharset());
System.out.println(request.getParameter(name) +  :  +
request.getParameter(name).getBytes(UTF-8).length);

which gives me :

Default Charset : windows-1252
Ã(c) : 4

It means that somewhere (from the form to the Struts Action), there's
a component which interpret the e-accute character with the latin1
encoding (ISO-8859-1). The result is that it sees TWO characters
(where it should only sees ONE character encoded by TWO bytes). When I
arrive to my Struts Action, my parameter is already the A-tild (c)
encoded IN UTF-8, and then encoded BY 4 bytes.

Anyone can help me to understand the problem and how to solve it ?

Thanks in advance,

piloupy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: UTF-8 charset issue

2007-05-03 Thread piloupy GOTTAPIL

Hi,

I've accidentally found a solution. I must put the directive on the
top of my pages :

%@ page contentType=text/html; charset=ISO-8859-15 %

because I've put previously :

%@ page contentType=text/html; charset=UTF-8 %

The result of my little trace gives me :

Default Charset : windows-1252
é : 2

I don't really understand why but... it works ^_^;

I'm still interested in knowing the reason, if you have the answer :)

Thanks,

piloupy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: UTF-8 charset issue

2007-05-03 Thread Cristian Lucero

Hi,
or good put this meta in head section
meta http-equiv=Content-Type content=text/html;
charset=ISO-8859-1/meta

On 5/3/07, piloupy GOTTAPIL [EMAIL PROTECTED] wrote:


Hi,

I've accidentally found a solution. I must put the directive on the
top of my pages :

%@ page contentType=text/html; charset=ISO-8859-15 %

because I've put previously :

%@ page contentType=text/html; charset=UTF-8 %

The result of my little trace gives me :

Default Charset : windows-1252
é : 2

I don't really understand why but... it works ^_^;

I'm still interested in knowing the reason, if you have the answer :)

Thanks,

piloupy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Cristian Lucero


Re: UTF-8 charset issue

2007-05-03 Thread Allen Gilliland
I haven't looked at this in my application yet (but i probably should 
:/), but the struts.properties default config has this ...


### This can be used to set your default locale and encoding scheme
# struts.locale=en_US
struts.i18n.encoding=UTF-8

I would assume that means that struts2 should be trying to set the 
encoding on incoming request objects to UTF-8 or whatever other value 
you may put in there.  It's possible that if something else in your 
application touches the request before struts, like a filter for 
example, then that may be disrupting things.


What you are doing in your jsps is correct, but won't solve your 
problem.  Setting the content type in your jsp is just for identifying 
to the browser what language the response is in.


http://struts.apache.org/2.x/docs/strutsproperties.html

-- Allen


Cristian Lucero wrote:

Hi,
or good put this meta in head section
meta http-equiv=Content-Type content=text/html;
charset=ISO-8859-1/meta

On 5/3/07, piloupy GOTTAPIL [EMAIL PROTECTED] wrote:


Hi,

I've accidentally found a solution. I must put the directive on the
top of my pages :

%@ page contentType=text/html; charset=ISO-8859-15 %

because I've put previously :

%@ page contentType=text/html; charset=UTF-8 %

The result of my little trace gives me :

Default Charset : windows-1252
é : 2

I don't really understand why but... it works ^_^;

I'm still interested in knowing the reason, if you have the answer :)

Thanks,

piloupy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: response.setContentType(text/html; charset=utf-8)

2006-09-21 Thread Al Eridani

On 9/8/06, Raghuveer [EMAIL PROTECTED] wrote:


From the source examples
jakarta-struts-1.1-src\jakarta-struts-1.1-src\src\upload\org\apache\struts\w
ebapp\upload

What does the use of
 response.setContentType(text/html; charset=utf-8);


It tells the browser that what the browser is going to receive uses
the UTF-8 character
set, so the browser can display it correctly.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



response.setContentType(text/html; charset=utf-8)

2006-09-08 Thread Raghuveer

From the source examples
jakarta-struts-1.1-src\jakarta-struts-1.1-src\src\upload\org\apache\struts\w
ebapp\upload

What does the use of
 response.setContentType(text/html; charset=utf-8);


---
/this line is here for when the input page is upload-utf8.jsp,
//it sets the correct character encoding for the response
String encoding = request.getCharacterEncoding();
if ((encoding != null)  (encoding.equalsIgnoreCase(utf-8)))
{
response.setContentType(text/html; charset=utf-8);
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: query about application resource and charset

2006-03-16 Thread Antonio Petrelli

Roy, Ansuman ha scritto:

Thanks Antonio,
that solved the problem. I used java.util.Properties so now the special 
characters are not coming

by the way, what if I try to put russian characters or use non ascii characters 
in my keys??
  
You'll find a lot of \u, not very readable ;-) What I can say is 
that Italian stressed characters are converted the \u way.

what would be the display like for example the Pound symbol
  

Do you mean '£'? \u00A3 if I am correct
Ciao
Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: query about application resource and charset

2006-03-16 Thread Roy, Ansuman
yes... £ symbol

-Original Message-
From: Antonio Petrelli [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 16, 2006 2:49 PM
To: Struts Users Mailing List
Subject: Re: query about application resource and charset


Roy, Ansuman ha scritto:
 Thanks Antonio,
 that solved the problem. I used java.util.Properties so now the special 
 characters are not coming

 by the way, what if I try to put russian characters or use non ascii 
 characters in my keys??
   
You'll find a lot of \u, not very readable ;-) What I can say is 
that Italian stressed characters are converted the \u way.
 what would be the display like for example the Pound symbol
   
Do you mean '£'? \u00A3 if I am correct
Ciao
Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: query about application resource and charset

2006-03-15 Thread Antonio Petrelli

Roy, Ansuman ha scritto:

Hi,
I have a content management system that generates the application 
resources.properties file. Now the value of many keys
are found to be of filled with  keys.
File .properties MUST have escape codes for special characters (i.e. 
\u codes). This is the default behaviour when you save a 
.properties file directly from Properties.store. I suppose that you 
don't use Properties at all...

Now you have two options:
a) use Properties in your code
b) use jdk-dir/bin/native2ascii utility by Sun.
I suggest, anyway, the first solution.
Ciao
Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: query about application resource and charset

2006-03-15 Thread Roy, Ansuman
Thanks a lot for the info. But the way I go about is 

html file  xslt-- xml file --java code -- . properties file

But the struts application uses bean tags every where so I have to generate the 
property file
any further suggestion,
regards,
Anshuman

-Original Message-
From: Antonio Petrelli [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 15, 2006 4:32 PM
To: Struts Users Mailing List
Subject: Re: query about application resource and charset


Roy, Ansuman ha scritto:
 Hi,
 I have a content management system that generates the application 
 resources.properties file. Now the value of many keys
 are found to be of filled with  keys.
File .properties MUST have escape codes for special characters (i.e. 
\u codes). This is the default behaviour when you save a 
.properties file directly from Properties.store. I suppose that you 
don't use Properties at all...
Now you have two options:
a) use Properties in your code
b) use jdk-dir/bin/native2ascii utility by Sun.
I suggest, anyway, the first solution.
Ciao
Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: query about application resource and charset

2006-03-15 Thread Antonio Petrelli

Roy, Ansuman ha scritto:

But the struts application uses bean tags every where so I have to generate the 
property file
  

How do you generate this file then?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: query about application resource and charset

2006-03-15 Thread Roy, Ansuman
using key value pairs. Basically the xml file has 

block
keyhello.name/key
valueRoy/value
/block
I parse through the xml and using io i write it into a .properties file

I think instead of java io i should use java.util's property class is it??

regards,
Anshuman

-Original Message-
From: Antonio Petrelli [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 15, 2006 5:33 PM
To: Struts Users Mailing List
Subject: Re: query about application resource and charset


Roy, Ansuman ha scritto:
 But the struts application uses bean tags every where so I have to generate 
 the property file
   
How do you generate this file then?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: query about application resource and charset

2006-03-15 Thread Antonio Petrelli

Roy, Ansuman ha scritto:

I parse through the xml and using io i write it into a .properties file

I think instead of java io i should use java.util's property class is it??
  
Yes, java.util.Properties. .properties files must be ASCII 7-bit, the 
Properties class takes all the burden of encoding.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: query about application resource and charset

2006-03-15 Thread Roy, Ansuman
Thanks Antonio,
that solved the problem. I used java.util.Properties so now the special 
characters are not coming

by the way, what if I try to put russian characters or use non ascii characters 
in my keys??

would it be converted to ascii and what would be the display like for example 
the Pound symbol

regards,
Roy

-Original Message-
From: Antonio Petrelli [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 15, 2006 6:17 PM
To: Struts Users Mailing List
Subject: Re: query about application resource and charset


Roy, Ansuman ha scritto:
 I parse through the xml and using io i write it into a .properties file

 I think instead of java io i should use java.util's property class is it??
   
Yes, java.util.Properties. .properties files must be ASCII 7-bit, the 
Properties class takes all the burden of encoding.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



query about application resource and charset

2006-03-14 Thread Roy, Ansuman
Hi,
I have a content management system that generates the application 
resources.properties file. Now the value of many keys
are found to be of filled with  keys. Basically this happens due to non 
conformant utf standards.
If this is present in the jsps or the html pages then these characters are not 
displayed because both the 
jsp and the included html is utf encoded. But when I take keys from the the 
property file the ÂÂ values are apearing again.
I have added the following line to the jsps:
%@ page language=java pageEncoding=utf8 contentType=text/html; 
charset=UTF8% 

but no result,
How do i solve this problem,
regards,
Ansuman




This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[HELP] I couldn't trim() 1 japanese String (charset UTF-8)

2005-06-21 Thread Pham Anh Tuan
Hi all,

I got 1 problem when I trying to eliminate spaces at ride side and left side of 
1 japanese String.

In mySQL I set UTF-8 for both database and my Jsp pages. But in Action, I can't 
not trim() japanese string, so, when I insert that string to database, spaces 
are exist.

Plz help me solve this problem! :(

Thanks for ur reading.

Pham

Re: [HELP] I couldn't trim() 1 japanese String (charset UTF-8)

2005-06-21 Thread matsuhashi

Do you want to remove leading/trailing double-bytes-whitespace chars?

I mean the double-bytes-whitespace to be a UNICODE char of \u3000.

The java.lang.String#trim() does not see the \u3000 as a whitespace which
it should chop off.

To remove the \u3000 char, I think you would need fair amount of custom
code. Following dirty code may suggest you something.


---
class DoubleBytesWhitespaceTrimmer {

static char doubleBytesWhitespace = '\u3000' ;

public static String trim(String s) {
  String leadingTrimmed = trimLeadingChar(s , doubleBytesWhitespace);
  String rev = reverse(leadingTrimmed);
return reverse(trimLeadingChar(rev , doubleBytesWhitespace));
}

private static String trimLeadingChar(String s , char c) {
  char[] chars = s.toCharArray();
StringBuffer b = new StringBuffer();
int index;
for (index = 0; index  chars.length; index++) {
if (chars[index] == c)
  ;
else
  break;
}
for ( ;index  chars.length; index++) {
b.append(chars[index]);
}
return b.toString();
}

private static String reverse(String s) {
  char[] chars = s.toCharArray();
  StringBuffer b = new StringBuffer();
  for (int x = chars.length - 1; x = 0 ; x--) {
b.append(chars[x]);
  }
  return b.toString();
}

public static void main(String[] args) {
StringBuffer b = new StringBuffer();
b.append(doubleBytesWhitespace);
b.append(foo);
b.append(doubleBytesWhitespace);
System.out.println(source : [ + b.toString() + ]);
String trimmed= DoubleBytesWhitespaceTrimmer.trim(b.toString());
System.out.println(trimed : [ + trimmed + ]);
System.out.println(\foo\.equals(\ + trimmed + \) ?  +
foo.equals(trimmed));
}
}
---


This gives following output for me.
---
source : [ foo ]
trimed : [foo]
foo.equals(foo) ? true







  
  Pham Anh Tuan   
  
  [EMAIL PROTECTED] 宛先:Struts Users 
Mailing List user@struts.apache.org  
  rp.jp   cc:  
  
   件名:[HELP] I couldn't 
trim() 1 japanese String (charset UTF-8)
  2005/06/21 20:03  
  
  Struts Users 
  
  Mailing List へ 
   
  返信してください  
  

  

  




Hi all,

I got 1 problem when I trying to eliminate spaces at ride side and left
side of 1 japanese String.

In mySQL I set UTF-8 for both database and my Jsp pages. But in Action, I
can't not trim() japanese string, so, when I insert that string to
database, spaces are exist.

Plz help me solve this problem! :(

Thanks for ur reading.

Pham





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [HELP] I couldn't trim() 1 japanese String (charset UTF-8)

2005-06-21 Thread Pham Anh Tuan

Matsuhashi, thank you very very much, my problem is solved :)

- Original Message - 
From: [EMAIL PROTECTED]

To: Struts Users Mailing List user@struts.apache.org
Sent: Tuesday, June 21, 2005 7:02 PM
Subject: Re: [HELP] I couldn't trim() 1 japanese String (charset UTF-8)




Do you want to remove leading/trailing double-bytes-whitespace chars?

I mean the double-bytes-whitespace to be a UNICODE char of \u3000.

The java.lang.String#trim() does not see the \u3000 as a whitespace which
it should chop off.

To remove the \u3000 char, I think you would need fair amount of custom
code. Following dirty code may suggest you something.


---
class DoubleBytesWhitespaceTrimmer {

   static char doubleBytesWhitespace = '\u3000' ;

   public static String trim(String s) {
 String leadingTrimmed = trimLeadingChar(s , doubleBytesWhitespace);
 String rev = reverse(leadingTrimmed);
   return reverse(trimLeadingChar(rev , doubleBytesWhitespace));
   }

   private static String trimLeadingChar(String s , char c) {
 char[] chars = s.toCharArray();
   StringBuffer b = new StringBuffer();
   int index;
   for (index = 0; index  chars.length; index++) {
   if (chars[index] == c)
 ;
   else
 break;
   }
   for ( ;index  chars.length; index++) {
   b.append(chars[index]);
   }
   return b.toString();
   }

   private static String reverse(String s) {
 char[] chars = s.toCharArray();
 StringBuffer b = new StringBuffer();
 for (int x = chars.length - 1; x = 0 ; x--) {
   b.append(chars[x]);
 }
 return b.toString();
   }

   public static void main(String[] args) {
   StringBuffer b = new StringBuffer();
   b.append(doubleBytesWhitespace);
   b.append(foo);
   b.append(doubleBytesWhitespace);
   System.out.println(source : [ + b.toString() + ]);
   String trimmed= DoubleBytesWhitespaceTrimmer.trim(b.toString());
   System.out.println(trimed : [ + trimmed + ]);
   System.out.println(\foo\.equals(\ + trimmed + \) ?  +
foo.equals(trimmed));
   }
}
---


This gives following output for me.
---
source : [ foo ]
trimed : [foo]
foo.equals(foo) ? true







 Pham Anh Tuan
 [EMAIL PROTECTED] 宛先:Struts Users 
Mailing List user@struts.apache.org

 rp.jp   cc:
  件名:[HELP] I couldn't 
trim() 1 japanese String (charset UTF-8)

 2005/06/21 20:03
 Struts Users
 Mailing List へ
 返信してください






Hi all,

I got 1 problem when I trying to eliminate spaces at ride side and left
side of 1 japanese String.

In mySQL I set UTF-8 for both database and my Jsp pages. But in Action, I
can't not trim() japanese string, so, when I insert that string to
database, spaces are exist.

Plz help me solve this problem! :(

Thanks for ur reading.

Pham





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[HELP] I couldn't trim() 1 japanese String (charset UTF-8)

2005-06-21 Thread Pham Anh Tuan

Matsuhashi, thank you very very much, my problem is solved :)

- Original Message - 
From: [EMAIL PROTECTED]

To: Struts Users Mailing List user@struts.apache.org
Sent: Tuesday, June 21, 2005 7:02 PM
Subject: Re: [HELP] I couldn't trim() 1 japanese String (charset UTF-8)




Do you want to remove leading/trailing double-bytes-whitespace chars?

I mean the double-bytes-whitespace to be a UNICODE char of \u3000.

The java.lang.String#trim() does not see the \u3000 as a whitespace which
it should chop off.

To remove the \u3000 char, I think you would need fair amount of custom
code. Following dirty code may suggest you something.


---
class DoubleBytesWhitespaceTrimmer {

   static char doubleBytesWhitespace = '\u3000' ;

   public static String trim(String s) {
 String leadingTrimmed = trimLeadingChar(s , doubleBytesWhitespace);
 String rev = reverse(leadingTrimmed);
   return reverse(trimLeadingChar(rev , doubleBytesWhitespace));
   }

   private static String trimLeadingChar(String s , char c) {
 char[] chars = s.toCharArray();
   StringBuffer b = new StringBuffer();
   int index;
   for (index = 0; index  chars.length; index++) {
   if (chars[index] == c)
 ;
   else
 break;
   }
   for ( ;index  chars.length; index++) {
   b.append(chars[index]);
   }
   return b.toString();
   }

   private static String reverse(String s) {
 char[] chars = s.toCharArray();
 StringBuffer b = new StringBuffer();
 for (int x = chars.length - 1; x = 0 ; x--) {
   b.append(chars[x]);
 }
 return b.toString();
   }

   public static void main(String[] args) {
   StringBuffer b = new StringBuffer();
   b.append(doubleBytesWhitespace);
   b.append(foo);
   b.append(doubleBytesWhitespace);
   System.out.println(source : [ + b.toString() + ]);
   String trimmed= DoubleBytesWhitespaceTrimmer.trim(b.toString());
   System.out.println(trimed : [ + trimmed + ]);
   System.out.println(\foo\.equals(\ + trimmed + \) ?  +
foo.equals(trimmed));
   }
}
---


This gives following output for me.
---
source : [ foo ]
trimed : [foo]
foo.equals(foo) ? true







 Pham Anh Tuan
 [EMAIL PROTECTED] 宛先:Struts Users 
Mailing List user@struts.apache.org

 rp.jp   cc:
  件名:[HELP] I couldn't 
trim() 1 japanese String (charset UTF-8)

 2005/06/21 20:03
 Struts Users
 Mailing List へ
 返信してください






Hi all,

I got 1 problem when I trying to eliminate spaces at ride side and left
side of 1 japanese String.

In mySQL I set UTF-8 for both database and my Jsp pages. But in Action, I
can't not trim() japanese string, so, when I insert that string to
database, spaces are exist.

Plz help me solve this problem! :(

Thanks for ur reading.

Pham





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Charset

2005-02-08 Thread Markos Charatzas
Hi there,

Although,

1. I have defined a controller in struts-config.xml like the following
controller contentType=text/html; charset=ISO-8859-7/

2. my html templates have the content type set properly
3. my resource files are in the corrent content type

I still get question marks (?) displayed back to the browser :(
Is there any other place I need to set the charset?

Thanks in advance.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



form accept-charset

2004-07-11 Thread Carl-Eric Menzel
Hi,

is there any special reason why the html:form tag doesn't support the
accept-charset attribute defined in HTML 4.01? I would very much like
to use this to make my charset handling at least a little bit cleaner.
Right now I'm sending all responses in UTF8, and am assuming that the
browsers send the same charset back.

Is this planned for Struts? If not, is there any way I can add it
myself?

Thanks
Carl-Eric
-- 
Antwort: Weil es das Lesen des Textes erschwert.   | Carl-Eric Menzel
Frage  : Warum ist das so schlimm? | PGP ID: 808F4A8E
Antwort: Antworten oben zu schreiben.  | Bitte keine HTML-
Frage  : Was ist die schlimmste Unsitte in Emails? | Mails schicken.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]