我在lua中创建了一个包含以下代码的文件:
local f = io.open("./data/myfile.html", "w")
f:write(text)
f:close()
字符串存储在文件中是波斯语。打开文件时,字母难以辨认。如下面的截图:
我如何解决?
答案 0 :(得分:2)
Lua不关心编码。如果您的Lua源文本已经在utf-8中,那么您应该在html“head”部分添加“meta”标记。
package dow;
import java.util.Arrays;
public class DOW
{
public static void main(String[] args)
{
BufferedReader reader = new BufferedReader(new FileReader("in.txt"));
BufferedWriter writer = new BufferedWriter(new FileWriter("out.txt"));
int dow = 0;
int temperature = 0;
int[] highArray = new int [8];
int[] lowArray = new int [8];
int[] countArray = new int [8];
int[] totalArray = new int [8];
// initialize array
for (dow = 0; dow <8; dow++)
{
highArray [dow]= -999;
lowArray [dow]= 999;
}
String nextLine;
while ((nextLine = reader.nextLine()) != null && !nextLine.isEmpty())
{
//DO STUFF
}
reader.close();
writer.write(Arrays.toString(highArray));
writer.close();
}
}
如果你的html版本早于html5,那么使用旧的construct:
<head>
<meta charset="UTF-8">
</head>