Thread: Unicode!
I use PostgreSQL 8!
I have 2 file:
insert.htm
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form name="form1" method="post" action="postgre_insert.jsp" >
<input type="text" name="username">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form name="form1" method="post" action="postgre_insert.jsp" >
<input type="text" name="username">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
postgre_insert.jsp
<%@ page contentType="text/html; charset=utf-8" import="java.sql.*" errorPage="" %>
<%
String username=request.getParameter("username");
String str="insert into user_table values('"+username+"','try')";
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/try";
Connection conn = DriverManager.getConnection(url, "postgres", "pass");
PreparedStatement s = conn.prepareStatement(str);
s.executeUpdate();
out.println("OK");
%>
<%@ page contentType="text/html; charset=utf-8" import="java.sql.*" errorPage="" %>
<%
String username=request.getParameter("username");
String str="insert into user_table values('"+username+"','try')";
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/try";
Connection conn = DriverManager.getConnection(url, "postgres", "pass");
PreparedStatement s = conn.prepareStatement(str);
s.executeUpdate();
out.println("OK");
%>
I input "Tiếng Việt" on textfield and click Submit button. Insertion is successed.
But, when i view data in pgAdmin III(version 1.2.0), data is " Ti���ng Vi��t ".
Can you help me!?
But, when i view data in pgAdmin III(version 1.2.0), data is " Ti���ng Vi��t ".
Can you help me!?
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
First, I would try to set encoding (charset) for the insert.htm page to UTF-8. That might help. If not, let us know. Miroslav Šulc star star wrote: > I use PostgreSQL 8! > > I have 2 file: > insert.htm > <html> > <head> > <title>Untitled Document</title> > <meta http-equiv="Content-Type" content="text/html; "> > </head> > <body> > <form name="form1" method="post" action="postgre_insert.jsp" > > <input type="text" name="username"> > <input type="submit" name="Submit" value="Submit"> > </form> > </body> > </html> > postgre_insert.jsp > <%@ page contentType="text/html; charset=utf-8" import="java.sql.*" > errorPage="" %> > <% > String username=request.getParameter("username"); > String str="insert into user_table values('"+username+"','try')"; > Class.forName("org.postgresql.Driver"); > String url = "jdbc:postgresql://localhost:5432/try"; > Connection conn = DriverManager.getConnection(url, "postgres", "pass"); > PreparedStatement s = conn.prepareStatement(str); > s.executeUpdate(); > out.println("OK"); > %> > I input "Tiếng Việt" on textfield and click Submit button. Insertion > is successed. > But, when i view data in pgAdmin III(version 1.2.0), data is " Tiếng > Việt ". > Can you help me!? > > ------------------------------------------------------------------------ > Do you Yahoo!? > Yahoo! Small Business - Try our new resources site! > <http://us.rd.yahoo.com/evt=31637/*http://smallbusiness.yahoo.com/resources/>
Attachment
Since you used Java JDBC to insert the data into PostgreSQL, can you also JDBC to pull it out back and see if you get the right data back? If not, then your database encoding is probably the error. You need to set the DB encoding properly. If you can get your data back to the correct encoding, then check the environment settings of your pgadmin III. I don't quite remember which version of pgadmin always gave me that problem too when I used it in chinese environment. My data in the DB is correct, and I can get it back in the right encoding, but pgadmin just does not display correctly, even though other applications running in the same environment settings can display unicode correctly. Not sure if you are running Linux or Windows. If you run Linux, you can set your environments to UTF-8, then connect to the DB with psql, and display the contents of your data. If your data are in unicode, you should see the display correctly. csp 在 2005-03-10四的 17:20 -0800,star star写道: > I use PostgreSQL 8! > > I have 2 file: > > insert.htm > <html> > <head> > <title>Untitled Document</title> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> > </head> > <body> > <form name="form1" method="post" action="postgre_insert.jsp" > > <input type="text" name="username"> > <input type="submit" name="Submit" value="Submit"> > </form> > </body> > </html> > > postgre_insert.jsp > <%@ page contentType="text/html; charset=utf-8" import="java.sql.*" > errorPage="" %> > <% > String username=request.getParameter("username"); > String str="insert into user_table values('"+username+"','try')"; > Class.forName("org.postgresql.Driver"); > String url = "jdbc:postgresql://localhost:5432/try"; > Connection conn = DriverManager.getConnection(url, "postgres", > "pass"); > PreparedStatement s = conn.prepareStatement(str); > s.executeUpdate(); > out.println("OK"); > %> > I input "Tiếng Việt" on textfield and click Submit button. Insertion > is successed. > But, when i view data in pgAdmin III(version 1.2.0), data is " Ting > Vi‡t ". > Can you help me!? > -- 陈少鹏 Chen Shaopeng 上海龙方信息技术有限公司 http://www.idsignet.com