C# html url中文乱码转换成中文

gxxloveszj 2013-01-23 04:24:00
我将一个网页的源文件下载下来了,但是html代码中,有一个超链接,超链接是中文名的一个文件,但在html上是乱码:%E6%8B%9B%E8%81%98%E7%AE%80%E7%AB%A0%E6%A0%B7%E6%9C%AC.doc,现在我想要将%E6%8B%9B%E8%81%98%E7%AE%80%E7%AB%A0%E6%A0%B7%E6%9C%AC转换为中文,但是一直没找到方法,求解啊
...全文
559 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
给力熊猫伟 2013-02-22
  • 打赏
  • 举报
回复
楼主找到解决方案了吗,同求
  • 打赏
  • 举报
回复
        string _s = "%E6%8B%9B%E8%81%98%E7%AE%80%E7%AB%A0%E6%A0%B7%E6%9C%AC.doc";
        Response.Write(HttpUtility.UrlDecode(_s,System.Text.Encoding.UTF8));
gxxloveszj 2013-01-23
  • 打赏
  • 举报
回复
引用 2 楼 showbo 的回复:
XML/HTML code?123<script>alert(decodeURIComponent('%E6%8B%9B%E8%81%98%E7%AE%80%E7%AB%A0%E6%A0%B7%E6%9C%AC.doc'))</script>
我在后台获取到这一串乱码字符串,怎样在后台转换
  • 打赏
  • 举报
回复
<script>
alert(decodeURIComponent('%E6%8B%9B%E8%81%98%E7%AE%80%E7%AB%A0%E6%A0%B7%E6%9C%AC.doc'))
</script>
gxxloveszj 2013-01-23
  • 打赏
  • 举报
回复
在线等啊!!!!!!!!
1、解决中文问题 2、附字体 3、动态html拼接转pdf public static void htmlCodeComeString(String linkcss,String htmlCode, String outputFile,String title) throws Exception { OutputStream os = new FileOutputStream(outputFile); ITextRenderer renderer = new ITextRenderer(); renderer.setDocumentFromString(getConversionHtmlCode(linkcss,htmlCode,title)); ITextFontResolver fontResolver = renderer.getFontResolver(); URL fontPath = ItextUtil.class.getResource("simsun.ttc"); fontResolver.addFont(fontPath.toString(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); // 解决图片的相对路径问题 // renderer.getSharedContext().setBaseURL("file:/F:/teste/html/"); renderer.layout(); renderer.createPDF(os); System.out.println("======转换成功!"); os.close(); os.flush(); } public static void main(String[] args) { ItextUtil itextUtil = new ItextUtil(); String html = ""; html += ""; html += "企业信息"; html += " "; html += " "; html += " 登记日期"; html += " 2006-04-28"; html += " "; html += " "; html += " 纳税人编号"; html += " HSJIHKS002"; html += " "; html += " "; html += " 有效标志"; html += " Y"; html += " "; html += " "; html += " 社会信用代码"; html += " 916101317H"; html += " "; html += " "; html += " 评估机关代码"; html += " 盛世"; html += " "; html += " "; html += " 工商注销日期"; html += " 2006-04-28"; html += " "; html += " "; html += ""; String outputFile = "D:\\pdf\\aa.pdf"; try { itextUtil.htmlCodeComeString("",html,outputFile,""); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("生成结束!!!"); }

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧