Re: Encoding Problem ISO to UTF-8
On 5/14/05, Leon Rosenberg <[EMAIL PROTECTED]> wrote: > Hi, > > I have a small encoding problem, which drives me crazy... > > Our complete site is in ISO-8859-1 (which is java-default, as I understand > it). I mean, the charset of the page is ISO, and meta-tags in HTML are > telling the > browser that the page is ISO too. > Now the problem, that I have, is that I have to transmit some XML data to > another system (payment provider) which expects it in UTF-8. > The problem is that customer name can contain Umlauts (german characters: > äöü), and they come truncated on the other side: > > Like I'm sending "Ümlaut" and the other side gets �mlaut. > > I tried each conversion method I could think of sofar: > reinitializing the String as new String with reencoding: name = new > String(name.getBytes("ISO-8859-1"), "UTF-8") (in all combinations) > Using URLDecoder to decode parameters. > Using charsetencoded Writer (OutputStreamWriter writer = new > OutputStreamWriter(outStream, "UTF-8")). > and so on... > > Can anyone give me a hint? > > This problem is slowly driving me crazy > > regards > and thanx in advance > > Leon > > I recently needed to send some text encoded as UTF-8 over a TCP/IP socket. I did it like this and it worked: import java.nio.*; //for CharBuffer (and ByteBuffer) import java.nio.charset.*; //For Charset and CharsetEncoder OutputStream os = .. /* initialized somhow*/ String s = "some text to send"; //s can be anything that extends CharSequence CharsetEncoder ce = Charset.forName("UTF-8").newEncoder(); byte[] b = ce.encode(CharBuffer.wrap(s)).array(); os.write(b, 0, b.length); In another (production) project I used similar code - with SocketChannels because they have send methods for sending CharBuffers. Java Strings and chars are Unicode (size of type char is 2 bytes, 0 - 65535). -- Why? Because YES! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Encoding Problem ISO to UTF-8
Leon Rosenberg wrote: Hi, I have a small encoding problem, which drives me crazy... Our complete site is in ISO-8859-1 (which is java-default, as I understand Java uses the system default, which is locale dependant, so you can't just assume Latin 1. it). I mean, the charset of the page is ISO, and meta-tags in HTML are telling the browser that the page is ISO too. Make sure that you have the content type declared in your JSPs using an @page directive to be certain everything is sent using the encoding you expect. I'm not sure that meta tags are enough if the content type isn't set right. Now the problem, that I have, is that I have to transmit some XML data to another system (payment provider) which expects it in UTF-8. The problem is that customer name can contain Umlauts (german characters: äöü), and they come truncated on the other side: Like I'm sending "Ümlaut" and the other side gets �mlaut. I tried each conversion method I could think of sofar: reinitializing the String as new String with reencoding: name = new String(name.getBytes("ISO-8859-1"), "UTF-8") (in all combinations) Using URLDecoder to decode parameters. Using charsetencoded Writer (OutputStreamWriter writer = new OutputStreamWriter(outStream, "UTF-8")). and so on... Can anyone give me a hint? Once you have a String object, it's already been re-encoded. You need to make sure that when you set 'name' initially you're taking care of the encoding. request.setCharacterEncoding("ISO-8859-1"); String name = request.getParameter("name"); Then make sure to specify UTF-8 encoding when you write it out. L. This problem is slowly driving me crazy regards and thanx in advance Leon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Encoding Problem ISO to UTF-8
Hi, I have a small encoding problem, which drives me crazy... Our complete site is in ISO-8859-1 (which is java-default, as I understand it). I mean, the charset of the page is ISO, and meta-tags in HTML are telling the browser that the page is ISO too. Now the problem, that I have, is that I have to transmit some XML data to another system (payment provider) which expects it in UTF-8. The problem is that customer name can contain Umlauts (german characters: äöü), and they come truncated on the other side: Like I'm sending "Ümlaut" and the other side gets �mlaut. I tried each conversion method I could think of sofar: reinitializing the String as new String with reencoding: name = new String(name.getBytes("ISO-8859-1"), "UTF-8") (in all combinations) Using URLDecoder to decode parameters. Using charsetencoded Writer (OutputStreamWriter writer = new OutputStreamWriter(outStream, "UTF-8")). and so on... Can anyone give me a hint? This problem is slowly driving me crazy regards and thanx in advance Leon
Encoding Problem ISO to UTF-8
Hi, I have a small encoding problem, which drives me crazy... Our complete site is in ISO-8859-1 (which is java-default, as I understand it). I mean, the charset of the page is ISO, and meta-tags in HTML are telling the browser that the page is ISO too. Now the problem, that I have, is that I have to transmit some XML data to another system (payment provider) which expects it in UTF-8. The problem is that customer name can contain Umlauts (german characters: äöü), and they come truncated on the other side: Like I'm sending "Ümlaut" and the other side gets �mlaut. I tried each conversion method I could think of sofar: reinitializing the String as new String with reencoding: name = new String(name.getBytes("ISO-8859-1"), "UTF-8") (in all combinations) Using URLDecoder to decode parameters. Using charsetencoded Writer (OutputStreamWriter writer = new OutputStreamWriter(outStream, "UTF-8")). and so on... Can anyone give me a hint? This problem is slowly driving me crazy regards and thanx in advance Leon
Re: My OWN VALIDATOR
Im having a problem with validating a password field . THIS IS MY CODE infe validator.FMValidator class public static boolean validatePassword( Object bean, ValidatorAction va, Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, HttpServletRequest request){ //testing message System.out.println("ENTRO AL VALIDATOR"); return true; } MY VALIDATION XML is like this and the VALIDATOR RULES IM having this error May 14, 2005 1:27:36 PM org.apache.struts.validator.ValidatorForm validate SEVERE: validator.FMvalidator org.apache.commons.validator.ValidatorException: validator.FMvalidator at org.apache.commons.validator.ValidatorAction.loadValidationClass(Vali datorAction.java:646) at org.apache.commons.validator.ValidatorAction.executeValidationMethod( ValidatorAction.java:555) at org.apache.commons.validator.Field.validateForRule(Field.java:811) at org.apache.commons.validator.Field.validate(Field.java:890) at org.apache.commons.validator.Form.validate(Form.java:174) at org.apache.commons.validator.Validator.validate(Validator.java:367) at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java :112) at org.apache.struts.action.RequestProcessor.processValidate(RequestProc essor.java:921) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja va:206) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116 4) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:157) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp atcher.java:704) at org.apache.catalina.core.ApplicationDispatcher.processRequest(Applica tionDispatcher.java:474) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD ispatcher.java:409) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis patcher.java:312) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor. java:1056) at org.apache.struts.action.RequestProcessor.internalModuleRelativeForwa rd(RequestProcessor.java:994) at org.apache.struts.action.RequestProcessor.processValidate(RequestProc essor.java:959) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja va:206) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116 4) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard ContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
Re: NestedLazy Validation: fixed
Once again, Niall Thank You. Niall Pemberton wrote: Are you using the indexedListProperty in your validation.xml? depends="..."> Niall - Original Message - From: "Vincent" <[EMAIL PROTECTED]> Sent: Wednesday, May 11, 2005 8:10 PM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Plato is my friend, Aristotle is my friend, but my greatest friend is truth. - Isaac Newton - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]