Java url 的 utf-8 编码
我对 UTF-8 编码中的某些符号有疑问。 我正在阅读 http://wordki.pl 中的 index.html 以获取包含其名称的单词集列表。
它看起来像这样
<a href="THE LINK.html">THE NAME</a><span>(20)</span><img src="krecha.png">
,当名称有“Ł”时,它不起作用并在那里放“??”但“??”不是我可以用 ReplaceAll("str", "str") 进行更改的标志,因为我的控制台只是不显示隐藏在其后面的字符。
但是当我在 chrome/firefox 等中查看源代码时,它显示“Ł”。 所有其他有趣的符号,如“ó、ł、ą、ś”在我的程序中都运行良好。
所以我想问是否有办法改变“??”变成“Ł”?我尝试逐字节对其进行编码,但后来我丢失了所有其他符号,如“ó、ł、ą”等。
编辑:好的,我已经解决了问题 我需要将 *.java 文件保存为 UTF-8 : O
I have a problem with some symbols in UTF-8 encoding.
I am reading the index.html from http://wordki.pl to get the list of sets of words with their name.
it looks like this
<a href="THE LINK.html">THE NAME</a><span>(20)</span><img src="krecha.png">
and when THE NAME has "Ł" it doesent work and puts there "??" but the "??" is not a sign that i can change with replaceAll("str", "str") because my console just doesent show the char hidden behind it.
But when i view the source in chrome/firefox etc it shows "Ł".
And all the other funny signs like "ó, ł, ą, ś" work fine in my program.
So I am asking if there is a way to change the "??" into "Ł" ? I tried encoding it byte by byte but then i lose all the other signs like "ó, ł, ą" etc.
EDIT: Ok i have the problem solved
I needed to save my *.java file as UTF-8 : O
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将页面内容类型设置为
“UTF-8”
执行如下操作:
或
参阅此 URL 了解更多信息:
如何让 UTF-8 在 Java 中工作网络应用程序?
You should set the page content-type as
"UTF-8"
Do something like this:
OR
Refer this URL for more info:
How to get UTF-8 working in Java webapps?