汉字被换成问号

时间:2015-09-16 03:28:30

标签: java file internationalization arguments

请参阅我之前的问题:Cannot write chinese characters to a filename此问题与此类似,但稍有改动,导致该问题中的解决方案不再有效。

我现在尝试将文件名作为程序参数,如果字符是中文(或日语或类似字符),它们将被交换为Sub ImportBPlans() Dim BPlan As String, FullHTML As String, URL1 As String, Cut1 As String, T1 As String Dim FO As String, LO As String, Other1 As Long For i = 2 To LastRow T1 = WB1.Cells(i, 1).Value URL1 = "http://finance.yahoo.com/q/pr?s=" + T1 + "+Profile" FullHTML = GetHTML(URL1) BPlan = "&nbsp;</th></tr></table><p>" x = Len(FullHTML) FO = InStr(FullHTML, BPlan, CompareMethod.Text) + Len(BPlan) LO = InStr(FO, FullHTML, "<") Cut1 = Left(FullHTML, LO) Cut1 = Right(Cut1, FO - LO) WB5.Cells(i, 1).Value = Cut1 Next i End Sub Function GetHTML(URL As String) As String Dim HTML As String Dim htmlBDY As New HTMLDocument With CreateObject("MSXML2.XMLHTTP") .Open "GET", URL, False .Send htmlBDY.body.innerHTML = .responseText GetHTML = htmlBDY.body.outerHTML End With End Function ,我将获得例外。

运行配置&gt;常见&gt;编码= ?

计划参数:UTF-8

主:

你好.txt

例外:public static void main(String[] args) throws IOException { String fileName = args[0]; Writer out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream("C:/temp/"+fileName+".txt"), "UTF-8"));//Ex thrown out.close(); }

我该如何做到这一点?

0 个答案:

没有答案