简体   繁体   English

检索MySQL数据库中非英语字符插入的值

[英]Retrieving non-English characters inserted values in MySQL database

I am working on inserting non-English characters in the database which is UTF-8 enabled. 我正在努力在启用UTF-8的数据库中插入非英文字符。 I am able to insert non-English characters in the database. 我可以在数据库中插入非英文字符。 When I insert the URL (it passes through response of JSP and because UTF8 encoding is set, it's converted to UTF8 format) 当我插入URL时(它通过JSP的响应并且由于设置了UTF8编码,因此将其转换为UTF8格式)

"1" “ 1”

http://heenaparekh.com/category/%E0%AA%AF%E0%AA%BE%E0%AA%A4%E0%AB%8D%E0%AA%B0%E0%AA%BE%E0%AA%AA%E0%AB%8D%E0%AA%B0%E0%AA%B5%E0%AA%BE%E0%AA%B8/ http://heenaparekh.com/category/%E0%AA%AF%E0%AA%BE%E0%AA%A4%E0%AB%8D%E0%AA%B0%E0%AA%BE%E0%AA %AA%E0%AB%8D%E0%AA%B0%E0%AA%B5%E0%AA%BE%E0%AA%B8 /

it appears correctly in database table as 它在数据库表中正确显示为

"2" “ 2”

http://heenaparekh.com/category /યાતરાપરવાસ http://heenaparekh.com/category /યાતરાપરવાસ

But when I am trying to select the value with same string "1" which I used for inserting in the database (without passing through request and response of JSP) : 但是,当我尝试选择用于插入数据库的相同字符串“ 1”的值时(不传递JSP的请求和响应):

When the select statement is run with the link as same URL "1" , it is converted to URL "2" by request of JSP. 当select语句以相同的URL “ 1”链接运行时,将根据JSP的请求将其转换为URL “ 2”

When I want to select the rows with this URL, I am not able to extract as I am not able to convert URL "1" to URL "2" in my JSP application and I don't need to shift to different page so I have tried the following methods to convert it into URL "2" format: 当我想选择带有该URL的行时,由于无法在JSP应用程序中将URL “ 1”转换为URL “ 2” ,因此无法提取,因此无需切换到其他页面,因此尝试了以下方法将其转换为URL “ 2”格式:

I have tried converting my string to UTF-8 format but it's not helping. 我尝试将我的字符串转换为UTF-8格式,但没有帮助。 String is printed to be same. 字符串被打印为相同。 When I convert it using Entities class of Nutch to UTF8 format then also it is not fetching results, maybe as UTF8 conversion by response of JSP and Entities class are different. 当我使用Nutch的Entities类将其转换为UTF8格式时,它也不会获取结果,可能是由于JSP响应和Entities类的UTF8转换不同。

Please help me how to bring both the URLs to same format so that I can extract it from the database. 请帮助我如何将两个URL设置为相同的格式,以便可以从数据库中提取它们。

You need to URL-unencode rather than "UTF-unencode" the string. 您需要URL取消编码,而不是“ UTF取消编码”字符串。 Internally, Java stores strings as UTF-16, but that doesn't matter for your purposes. 在内部,Java将字符串存储为UTF-16,但这与您的目的无关。 Try the java.net.URLDecoder.decode(String, String) method. 尝试使用java.net.URLDecoder.decode(String, String)方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM