Re: Problems with umlauts

Dev WO <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi Roman,
in fact you don't even need to escape the characters as long as the  
HTML header and the web server header is correct.
The issue you are having is due to the web server header. WO doesn't  
send the correct header.
You need to add this in your Application.java:
-----------
	public void appendToResponse(WOResponse response, WOContext  
wocontext) {
		super.appendToResponse(response, wocontext);
		// This must be done after the page generation to override the  
default header created by WO during the page generation.
		if (_NSUtilities.UTF8StringEncoding.equals(response.contentEncoding 
()))
			response.setHeader("text/html; charset=UTF-8", "content-type");
	}
	
	public WOResponse createResponseInContext(WOContext wocontext) {
		WOResponse woresponse = super.createResponseInContext(wocontext);
		woresponse.setContentEncoding(_NSUtilities.UTF8StringEncoding);
		return woresponse;
	}
-----------
and if you have some form that may use umlaut characters, also add  
this in your Session.java:
-----------
	public void takeValuesFromRequest(WORequest aRequest, WOContext  
aContext){
		aRequest.setDefaultFormValueEncoding(_NSUtilities.UTF8StringEncoding);
		super.takeValuesFromRequest(aRequest, aContext);
	}
-----------
See the localisation chapter on Practical WebObjects book;)

Xavier



> Hi list
>
> During the developement of our application we've realised the  
> following:
>
> If you use a umlaut (e.g. ä,ö or ü) in the HTML-code (without a  
> WOString) and you set everything (WOComponent,XCode,HTML and the  
> browser) to UTF-8 encoding before, the browser displays the content  
> correctly. All the umlauts were converted from a character into a  
> character entity. Out of a ä you have then a &auml; in the .html- 
> file. So far, everything is ok.
>
> But if you put the same characters into a WOString, the characters  
> are no more displayed correctly. All umlauts are all displayed  
> wrong, they were not converted into html-entities (in the .WOO  
> file) and they do not seem to be UTF-8 standart characters.
>
> To explain that a little bit better, here a little code-example:
>
> .html:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
>   <head>
>     <meta http-equiv="Content-Type" content="text/html;  
> charset=utf-8" />
>     <title></title>
>   </head>
>   <body>
>   <!-- were converted to from  ä  to &auml; -->
>   &auml;&ouml;&uuml;<br> 		
>   <webobject name="String1"></webobject>
>   </body>
> </html>
>
> .wod
> String1: WOString
> {
> 	escapeHTML = false;
> 	value = "äöü";
> }
>
> .woo
> {"WebObjects Release" = "WebObjects 5.0"; encoding =  
> NSUTF8StringEncoding; }
>
> Even more interesting is the effect, when you use text out of a  
> database (also set to utf-8) and put it into a WOString. In this  
> case the characters are displayed correctly again !?
>
> I know, that I could directly use html-entities instead of  
> characters, when I'm using a static WOString. But what shall I do,  
> when I have to write in another language (with more special  
> characters)?
>
> Is it a bug, or have I overseen something. Or do I think in a wrong  
> direction and you would realise it completly different?
>
>
> Thanks in advance for your answers
>
> Roman
>
> (version: WOBuilder: 5.3.1, XCode: 2.2, Safari: 2.0.3)
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.