Step 1. First make sure the string has Chinese or non ASCII characters in it:
select asciiname from table1
where asciiname regexp(concat('[',char(128),'-',char(255),']'));
Step 2. If the Chinese name is definitely at the end of your field, you just need to trim the last occurrence of a space in your field. Confirm it is doing the right thing first:
select asciiname, reverse(substring(reverse(asciiname), locate(' ', reverse( asciiname ) )+1))
from table1
where asciiname regexp(concat('[',char(128),'-',char(255),']'));
Step 3. Execute:
update table1
set asciiname = reverse(substring(reverse(asciiname), locate(' ', reverse( asciiname ) )+1))
where asciiname regexp(concat('[',char(128),'-',char(255),']'));
My sources for this were (I am very grateful to):
1. http://stackoverflow.com/questions/461871/find-rows-with-non-ascii-values-in-a-column
2. http://dev.mysql.com/doc/refman/5.1/en/string-functions.html
Programming solutions, source code, solutions to tech problems and other tech related stuff.
Showing posts with label UTF-8. Show all posts
Showing posts with label UTF-8. Show all posts
Friday, November 25, 2011
Monday, June 15, 2009
Thursday, May 29, 2008
Compiling UTF-8 Encoded Files in Java
If the compiler is giving out warnings like:
"warning: unmappable character for encoding cp1252"
It is best to specify the exact encoding, as in:
javac -encoding UTF-8 JavaSourceFile.java
"warning: unmappable character for encoding cp1252"
It is best to specify the exact encoding, as in:
javac -encoding UTF-8 JavaSourceFile.java
Wednesday, February 27, 2008
UTF-8 Problem Between Apache and Tomcat via Mod_JK
If the UTF-8, GBK, Chinese or whatever character set it may be, is showing via Tomcat (i.e. accessing from port 8080) but not showing in Apache (via mod_jk) then one step might be to check that the AJP connector has the URIEncoding set too as mod_jk uses that connector rather than the one that might be set on port 8080.
For Example:
For Example:
Sunday, January 13, 2008
Pesky URLEncoder, JSP and UTF-8
Seems like request.getParameter in JSP doesn't like dealing with UTF-8 encoded strings much. Here's what I did to solve it:
Call from Java:
sURL += "?myparam="+URLEncoder.encode(sMyUTF8String, "UTF-8");
Necessary Code in JSP:
<%@ page contentType='text/html; charset=UTF-8' %>
request.setCharacterEncoding("UTF-8");
String sMyParam = new String(request.getParameter("myparam").getBytes("ISO8859_1"),"UTF8");
Call from Java:
sURL += "?myparam="+URLEncoder.encode(sMyUTF8String, "UTF-8");
Necessary Code in JSP:
<%@ page contentType='text/html; charset=UTF-8' %>
request.setCharacterEncoding("UTF-8");
String sMyParam = new String(request.getParameter("myparam").getBytes("ISO8859_1"),"UTF8");
Subscribe to:
Posts (Atom)