Re: [WSG] Internationalization for hindi (data getting corrupted while sendng from jsp to action)

2007-02-23 Thread Nick Fitzsimons

On 23 Feb 2007, at 06:55:01, Nisha Kumari wrote:


Hi

I have done all following changes in my jsp page. I am using struts  
and

even have saved my Hindi text in a application recourse file and have
save that file in a UTF-8 encoding format.

I can see in browser the encoding is getting set to UTF-8 because  
of the

jsp tag ([EMAIL PROTECTED] encoding=UTF-8
contentType=text/html;charset=UTF-8%).

But still its showing me something other than Hindi (may be garbag). I
tried commenting out the page encoding from jsp page and then I
explicitly changed the page encoding from browser then the text  
appears

perfectly in Hindi.

What could be the reason?


As manually changing the encoding in the browser shows the Hindi  
correctly, you are obviously sending the correct data, so that's not  
the problem.


When the browser attempts to identify the character set of the  
document, it looks first for a Content-Type HTTP header, and only if  
that isn't found does it look for a meta element specifying the  
character set - see [1]. I don't know Struts, but a look at the JSP  
documentation suggests that you should be using pageEncoding  
instead of encoding in your @page directive. [2] I don't know if  
this affects the Content-Type header, or just creates a meta  
element, though.


If changing that doesn't work, then I would suggest looking at the  
raw HTTP headers for your page, to see if the Content-Type header is  
correctly specifying UTF-8. If you use Firefox, there are various  
ways to do this via extensions such as Firebug, although going to  
Tools menu-Page Info may tell you what you need to know. Assuming  
you're using Microsoft Windows, a free application called Fiddler,  
written by a chap at Microsoft, will allow you to examine the raw  
HTTP traffic between your browser and your server [3]. If it turns  
out that the Content-Type header in the HTTP response is overriding  
any Meta element in the document, then you need to change your server  
configuration; at that point, my lack of knowledge of your  
configuration leaves me unable to help any further :-(


[1] http://www.w3.org/TR/html4/charset.html#h-5.2.2
[2] http://java.sun.com/products/jsp/syntax/1.2/ 
syntaxref1210.html#15653

[3] http://www.fiddlertool.com/fiddler/

HTH,

Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/





***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***



[WSG] Internationalization for hindi (data getting corrupted while sendng from jsp to action)

2007-02-22 Thread Nisha Kumari
Hi All.

I am trying to implement internationalization for my site. But when I am
trying to enter some Hindi text in a text box (struts html:text) the
value I m getting in my action is not expected one. Getting some
corrupted value rather than Hindi entered text.

I have set charset to utf-8 in the jsp page. Do I need to do any thing
more?


Regards,
Nisha




***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***



Re: [WSG] Internationalization for hindi (data getting corrupted while sendng from jsp to action)

2007-02-22 Thread Tee G. Peng


On Feb 22, 2007, at 4:53 AM, Nisha Kumari wrote:


Hi All.

I am trying to implement internationalization for my site. But when  
I am

trying to enter some Hindi text in a text box (struts html:text) the
value I m getting in my action is not expected one. Getting some
corrupted value rather than Hindi entered text.

I have set charset to utf-8 in the jsp page. Do I need to do any thing
more?


Hi Nisha,

I don't know Hindi, know no JSP so can't be of help!

But something you maybe overlook. Does your Hindi text unicode?  
Changing the charset to utf-8 directly from the header isn't good  
enough, you need the document to be utf-8 encoding. In Dreamwever and  
BBedit, I can change that from Preferences or 'properity'. And the  
Urdu/Hindi font needs to be Unicode font. If you use PC, Vista maybe  
come with Unicode fonts but I am not sure about XP though.


tee



***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***



Re: [WSG] Internationalization for hindi (data getting corrupted while sendng from jsp to action)

2007-02-22 Thread Lachlan Hunt

On Feb 22, 2007, at 4:53 AM, Nisha Kumari wrote:

I am trying to implement internationalization for my site. But when I am
trying to enter some Hindi text in a text box (struts html:text) the
value I m getting in my action is not expected one. Getting some
corrupted value rather than Hindi entered text.

I have set charset to utf-8 in the jsp page. Do I need to do any thing
more?


This is a little off topic for this list, but you need to check that you 
have handled all the encoding issues correctly.  You need to declare 
both the encoding of the actual JSP file and the encoding served to 
browsers.  Unfortunately, JSP defaults to ISO-8859-1 instead of UTF-8, 
but it's relatively easy to handle using the @page directive at the top 
of every JSP file.


[EMAIL PROTECTED] encoding=UTF-8 contentType=text/html;charset=UTF-8%

The encoding attribute specifies the actual encoding of the file (you 
need to ensure your editor is actually saving in UTF-8).  The 
contentType attribute specifies the HTTP Content-Type header to be sent 
to UAs.  If the  2 declared encodings differ, then JSP will transcode it 
before sending.


Ideally, there should be a way to set these as defaults in web.xml for 
the application server, but I've never successfully found a way to do it.


You should then verify that the document received by browses is actually 
encoded in UTF-8.  If you've done the above correctly, it will be, but 
check anyway.


Browsers will submit form data in the same encoding as the page.  So 
unless the user explicitly changes it from UTF-8, then it will be UTF-8. 
 Finally, you need to make sure your form processing on the server side 
is actually accepting and interpreting the form submission as UTF-8.  It 
should do so if you added the @page directive correctly.


--
Lachlan Hunt
http://lachy.id.au/


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***



RE: [WSG] Internationalization for hindi (data getting corrupted while sendng from jsp to action)

2007-02-22 Thread Nisha Kumari
Hi 

I have done all following changes in my jsp page. I am using struts and
even have saved my Hindi text in a application recourse file and have
save that file in a UTF-8 encoding format. 

I can see in browser the encoding is getting set to UTF-8 because of the
jsp tag ([EMAIL PROTECTED] encoding=UTF-8
contentType=text/html;charset=UTF-8%).

But still its showing me something other than Hindi (may be garbag). I
tried commenting out the page encoding from jsp page and then I
explicitly changed the page encoding from browser then the text appears
perfectly in Hindi. 

What could be the reason? 

Regards,
Nisha.


-Original Message-
From: listdad@webstandardsgroup.org
[mailto:[EMAIL PROTECTED] On Behalf Of Lachlan Hunt
Sent: Friday, February 23, 2007 6:11 AM
To: wsg@webstandardsgroup.org
Subject: Re: [WSG] Internationalization for hindi (data getting
corrupted while sendng from jsp to action)

On Feb 22, 2007, at 4:53 AM, Nisha Kumari wrote:
 I am trying to implement internationalization for my site. But when I
am
 trying to enter some Hindi text in a text box (struts html:text) the
 value I m getting in my action is not expected one. Getting some
 corrupted value rather than Hindi entered text.

 I have set charset to utf-8 in the jsp page. Do I need to do any thing
 more?

This is a little off topic for this list, but you need to check that you

have handled all the encoding issues correctly.  You need to declare 
both the encoding of the actual JSP file and the encoding served to 
browsers.  Unfortunately, JSP defaults to ISO-8859-1 instead of UTF-8, 
but it's relatively easy to handle using the @page directive at the top 
of every JSP file.

[EMAIL PROTECTED] encoding=UTF-8 contentType=text/html;charset=UTF-8%

The encoding attribute specifies the actual encoding of the file (you 
need to ensure your editor is actually saving in UTF-8).  The 
contentType attribute specifies the HTTP Content-Type header to be sent 
to UAs.  If the  2 declared encodings differ, then JSP will transcode it

before sending.

Ideally, there should be a way to set these as defaults in web.xml for 
the application server, but I've never successfully found a way to do
it.

You should then verify that the document received by browses is actually

encoded in UTF-8.  If you've done the above correctly, it will be, but 
check anyway.

Browsers will submit form data in the same encoding as the page.  So 
unless the user explicitly changes it from UTF-8, then it will be UTF-8.

  Finally, you need to make sure your form processing on the server side

is actually accepting and interpreting the form submission as UTF-8.  It

should do so if you added the @page directive correctly.

-- 
Lachlan Hunt
http://lachy.id.au/


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***




***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***