• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Unicode trouble
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unicode trouble


  • Subject: Unicode trouble
  • From: Jim Kuo <email@hidden>
  • Date: Thu, 18 Aug 2005 08:52:13 +0100

I am running WebObjects 5.3 in Tiger, with MySQL 4.1. I am having trouble getting UTF-8 contents in my .wo files to play together with the UTF-8 data in mysql database, I am hoping someone can help me.

If I have UTF-8 data in mysql database, all I have to do is to insert the following method in Application.java ,

    public void appendToResponse(WOResponse aResponse, WOContext aContext){
        aResponse.setHeader("text/html; charset=UTF-8", "Content-Type");
        super.appendToResponse(aResponse, aContext);
    }


I think this method will make the browser to treat the content retrieved or submitted as UTF-8 data, and this allows me to retrieve and insert UTF-8 data properly from and to the database. However, the above code is not enough if i also have UTF-8 data in my .wo files, after searching from the net, I found that I  need to add these  methods,

    public void appendToResponse(WOResponse aResponse, WOContext aContext){
        aResponse.setContentEncoding(_NSUtilities.UTF8StringEncoding);
        aResponse.setHeader("text/html; charset=UTF-8", "Content-Type");
        super.appendToResponse(aResponse, aContext);
    }

    public void takeValuesFromRequest(WORequest aRequest, WOContext aContext){
        aRequest.setDefaultFormValueEncoding(_NSUtilities.UTF8StringEncoding);
        aRequest.setFormValueEncodingDetectionEnabled(true);
        super.takeValuesFromRequest(aRequest, aContext);
    }


Unfortunately, the above two methods (i think aReponse.setContentEcoding in particular), break UTF-8 data handling, the data retrieved is shown as rubbish, and inserted as question marks (???).

I have tried playing around with JDBC Url

jdbc:mysql://localhost/mydb
jdbc:mysql://localhost/mydb?useUnicode=TRUE&characterEncoding=utf8

But none of the above seems to fix the problem.

So currently I am only able to get UTF-8 to display from either .wo or database, but not both. If anyone can share experience in UTF-8 in WebObjects, it would be very much appreciated.

Jim







 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Unicode trouble
      • From: Kushnir Gennady <email@hidden>
References: 
 >[Newbie] -> how to reference static files (css, images, etc)? (From: Miguel Arroz <email@hidden>)
 >Re: [Newbie] -> how to reference static files (css, images, etc)? (From: John Bruce <email@hidden>)

  • Prev by Date: Re: [Newbie] -> how to reference static files (css, images, etc)?
  • Next by Date: Re: Runtime.getRuntime().exec()
  • Previous by thread: Re: [Newbie] -> how to reference static files (css, images, etc)?
  • Next by thread: Re: Unicode trouble
  • Index(es):
    • Date
    • Thread