java amateur
Hauke Ingmar Schmidt wrote:Latin1 does not include the euro sign. ISO-8859-15/Latin9 does.
Bear Bibeault wrote:Any reason not to be using UTF-8?
java amateur
miguel lisboa wrote:
i just changed from latin1 to utf8 in mysql table charset but the problem is still there..
Hauke Ingmar Schmidt wrote:If you are free to choose: Use UTF-8, like Bear recommend, no question there.
Otherwise you could look up the alternative names that MySQL may use. I just fired up the MySQL query browser and am shocked by the incosistent and chaotic list there...
miguel lisboa wrote:
so so far i can conclude this is not an html issue, but instead a database problem?
Hauke Ingmar Schmidt wrote:
miguel lisboa wrote:
i just changed from latin1 to utf8 in mysql table charset but the problem is still there..
The problem is ... where exactly? You have to ensure that every part of the application, from data input to database connection to output uses the correct and specified encoding.
java amateur
miguel lisboa wrote:i just changed from latin1 to utf8 in mysql table charset but the problem is still there..
Hauke Ingmar Schmidt wrote:
miguel lisboa wrote:
so so far i can conclude this is not an html issue, but instead a database problem?
Sorry, no. Encoding problems can occur in every step of the application. But if the database can't hold the symbol there is no need to work at the higher layers. The problem can begin with entering the data into the db. Let's say you use the console program... then the encoding of the console can mangle with the characters.
If you still use the very same HTML fragment that you showed above then there is an encoding used that can't display the euro symbol.
Paul Clapham wrote:
miguel lisboa wrote:i just changed from latin1 to utf8 in mysql table charset but the problem is still there..
Well, yeah. You corrupted the data when you wrote it as latin1. Just telling MySQL that it should now treat the corrupt data as UTF-8 will not un-corrupt the data.
But Hauke Ingmar is correct. Let me point you to this article Character Conversions from Browser to Database which explains that concept in detail.
java amateur
miguel lisboa wrote:
what you are telling me is to change (inside my html) from charset = iso-8859-1 to charset = iso-8859-15?
Hauke Ingmar Schmidt wrote:
miguel lisboa wrote:
what you are telling me is to change (inside my html) from charset = iso-8859-1 to charset = iso-8859-15?
If you decided to go for UTF-8 then setting it to ISO-8859-15 is not a good idea.
Paul Clapham wrote:I used UTF-8 for my personal application which uses MySQL. It isn't a web application but I might make it into one in the near future.
You've already had one character which didn't exist in the charset you originally chose. Switching to ISO-8859-15 takes care of that one character. What do you do when that happens again? But if you choose UTF-8 then that problem goes away. So just use UTF-8.
java amateur
miguel lisboa wrote:pardon my total ignorance and confusion about all this: are you suggesting using UTF-8 with
1) mysql
2) within html
3) in both?
Add the following code just before reading any parameters in the previous JSP file.
String paramEncoding = application.getInitParameter("PARAMETER_ENCODING");
request.setCharacterEncoding(paramEncoding);
java amateur
Have Fun with Java
little,little.. little by little makes a lot..
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%
if (session.getAttribute("xxx") == null) {
response.sendRedirect(redirectURL);
return;
}
String paramEncoding = application.getInitParameter("PARAMETER_ENCODING");
request.setCharacterEncoding(paramEncoding);
if (session.getAttribute("xxx").equals("xxx")) {
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html dir = "ltr" lang = "pt">
<head>
<title>avulsas: escrever</title>
<!--<meta http-equiv = "Content-Type" content="text/html; charset=iso-8859-1">-->
<meta http-equiv = "Content-Type" content="text/html; charset=UTF-8">
<!DOCTYPE web-app PUBLIC
'-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
...
<context-param>
<param-name>PARAMETER_ENCODING</param-name>
<param-value>UTF-8</param-value>
</context-param>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<Service name="Catalina">
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector port="80" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
URIEncoding="UTF-8"
...
java amateur
6/Fev/2011 19:01:37 org.apache.tomcat.util.http.Parameters processParameters
WARNING: Parameters: Character decoding failed. Parameter skipped.
java.io.CharConversionException: isHexDigit
at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:87)
at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:48)
at org.apache.tomcat.util.http.Parameters.urlDecode(Parameters.java:411)
at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:393)
at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:344)
at org.apache.catalina.connector.Request.parseParameters(Request.java:2449)
at org.apache.catalina.connector.Request.getParameter(Request.java:1010)
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:353)
at blog.Escrever.doGet(Escrever.java:43) // empty line in my code
at blog.Escrever.doPost(Escrever.java:61) // empty line in my code
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
java amateur
:confused:Do you set the application init parameter to the correct value?
Hauke Ingmar Schmidt wrote:You have following in you JSP source:
I don't think the encoding problem should be your main interest now. I recommend working through some fundamental books or tutorials regarding this technologies.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |