>> [COLOR=#464646][FONT=Helvetica Neue]One or more fields in your database (which is a latin1_whatever) show the Euro symbol fine in PHPMyAdmin.
no, when i open mysql query browser, i already have a question mark
>> [/FONT][/COLOR][COLOR=#464646][FONT=Helvetica Neue] when you try to output these fields in a webpage, the Euro sign shows up as the question-mark.
yes
>> [/FONT][/COLOR]You are using the following meta tag on the page: <meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8” />
Is that correct?
no, i’m currently using <meta http-equiv = “Content-Type” content = “text/html; charset = iso-8859-1”> meta tag, but i tested with both [COLOR=#464646][FONT=Helvetica Neue]charset = iso-8859-15 and also with UTF-8
>> [/FONT][/COLOR][COLOR=#464646][FONT=Helvetica Neue]Could you provide the code you are using to read the data from the database and to output it on the page.
i think it would be also relevant posting the code to insert in bd
the servlet that inpust to db:
[/FONT][/COLOR]
package blog;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import bd.*;
public class Escrever extends HttpServlet {
private JdbcAccess access;
private int linhas;
public void init() throws ServletException {
access = new JdbcAccess("avulsas");
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String titulo = request.getParameter("titulo");
String texto = request.getParameter("texto");
long data = java.lang.System.currentTimeMillis() / 1000;
String sql = "INSERT INTO posts (data, titulo, texto) VALUES (" + data + ", '" + titulo + "', '" + texto + "')";
try {
linhas = access.executaUpdate(sql);
}
catch (SQLException msg) {}
response.setContentType("text/html");
if (linhas ==1) {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Escrever</title>");
out.println("<meta HTTP-EQUIV=\\"REFRESH\\" content=\\"0; url=http://rsacramento.no-ip.org/Blog\\"");
out.println("</head>");
out.println("<body>");
out.println("</body>");
out.println("</html>");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
doGet(request, response);
}
}
the servlet i use to read from db is next:
package blog;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import bd.*;
import util.*;
public class Avulsas extends HttpServlet {
private JdbcAccess access;
public void init() throws ServletException {
access = new JdbcAccess("avulsas");
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String sql = "SELECT * FROM posts order by data desc LIMIT 5";
String apagina = "";
try {
ResultSet rs = access.executaQuery(sql);
access.fecha(access.getConnection());
apagina = AvulsasUtil.formata(rs);
request.setAttribute("apagina", apagina);
getServletContext().getRequestDispatcher("/jsp/avulsas.jsp").forward(request, response);
}
catch (SQLException msg) {
// String erro = "De momento não é possível comunicar com a base de dados.<br /> Tente mais tarde.";
Object erro = msg.toString();
request.setAttribute("erro", erro);
getServletContext().getRequestDispatcher("/jsp/erro.jsp").forward(request, response);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
doGet(request, response);
}
}
and also:
package util;
import java.sql.*;
import java.text.*;
public class AvulsasUtil {
public static synchronized String formata(ResultSet rs) throws SQLException {
StringBuilder pagina = new StringBuilder();
String dataTemporaria = "";
while (rs.next()) {
long mili = rs.getLong(2);
mili = mili * 1000;
java.util.Date data = new java.util.Date(mili);
String padraoExtenso = "EEEEEE, d 'de' MMMMMM 'de' yyyy";
String padraoHora = "HH:mm";
SimpleDateFormat sdfExtenso = new SimpleDateFormat(padraoExtenso);
SimpleDateFormat sdfHora = new SimpleDateFormat(padraoHora);
String dataPorExtenso = sdfExtenso.format(data);
String dataHoraria = sdfHora.format(data);
String titulo = rs.getString(3);
String texto = rs.getString(4);
if (!dataTemporaria.equals(dataPorExtenso)) {
dataTemporaria = dataPorExtenso;
pagina.append("<h1>" + dataTemporaria + "</h1>\
");
pagina.append("<h2>" + titulo + "</h2>\
");
pagina.append("<p><span class = \\"horas\\">" +
dataHoraria +
" </span>" +
texto +
"</p>\
");
}
else {
pagina.append("<h2>" + titulo + "</h2>\
");
pagina.append("<p><span class = \\"horas\\">" +
dataHoraria +
" </span>" +
texto +
"</p>\
");
}
}
return pagina.toString();
}
}
hope it helps