如何写阿拉伯语,希伯来语到CSV文件? [英] How to write Arabic, Hebrew Into CSV file?

查看:140
本文介绍了如何写阿拉伯语,希伯来语到CSV文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能给Results.csv写任何阿拉伯语或希伯来语,除了英语。
每次我试图写任何一个,我会得到乱七八糟的标记,在CSV文件中应该有正确的阿拉伯语或希伯来语的话。

I can't write to Results.csv any of the languages Arabic or Hebrew, except English. Each time I'm trying to write any one of them I'm getting gibberish marks, in the CSV file where it should have proper Arabic or Hebrew words instead.

我一直在尝试使用UTF8Encoding,但我显然做错了。

I've been trying to use UTF8Encoding, but I'm obviously doing something wrong.

请看看,并尝试纠正我:

Please take a look and try to correct me:

private void WriteToCsvFile()
{
    var us = users.ElementAt(0);
    string titlenames = "number,";
    string userAnswer = (us.userName + ",");
    foreach (string ss in List)
    {
        // Do stuff
    }
    foreach (string ans in us.answer)
    {
        // Do stuff
    }
    using (StreamWriter sw = new StreamWriter("Results.csv", true, Encoding.UTF8))
    {
        sw.WriteLine(titlenames);
        sw.WriteLine(userAnswer);
    }
    this.Close();
}

感谢您的时间和帮助!

以下是包含不同类型的编码的CSV文件:

Here is the CSV file with different kinds of Encoding:

number  לוי  סל    רמי  שופר    ×ב×ל×"    ×‘×•×   ללונ×"  פ×רק
22  FALSE   TRUE    FALSE   FALSE   TRUE    TRUE    FALSE   FALSE

number  לוי  סל    רמי  שופר    ×ב×ל×"    ×‘×•×   ללונ×"  פ×רק
33  TRUE    TRUE    FALSE   FALSE   FALSE   FALSE   TRUE    FALSE

number  +BdwF1QXZ-  +BeEF3A-    +BegF3gXZ-  +BekF1QXkBeg-   +BdAF0QXQBdwF1A-    +BdEF1QXQ-  +BdwF3AXVBeAF1A-    +BeQF0AXoBec-
22  FALSE   FALSE   FALSE   TRUE    TRUE    TRUE    FALSE   TRUE

number  ÜÕÙ áÜ  èÞÙ éÕäè    ÐÑÐÜÔ   ÑÕÐ ÜÜÕàÔ   äÐèç
33  TRUE    TRUE    FALSE   TRUE    FALSE   TRUE    TRUE    FALSE

number  ÜÕÙ áÜ  èÞÙ éÕäè    ÐÑÐÜÔ   ÑÕÐ ÜÜÕàÔ   äÐèç
44  not answered    not answered    FALSE   not answered    not answered    not answered    not answered    not answered

number  ??? ??  ??? ????    ?????   ??? ?????   ????
55  not answered    not answered    not answered    not answered    not answered    not answered    not answered    not answered

推荐答案

你说你得到了乱码您的CSV文件。这不是因为你使用错误的编码,但是(很可能),因为你是使用错误的编码查看。

You say you are getting "gibberish marks" in your CSV file. That is not because you are writing using the wrong encoding, but that is (most likely) because you are viewing it using the wrong encoding.

尝试使用文本编辑器(如记事本+)打开CSV文件。在编码菜单中选择UTF8。你应该看到正确的字符了。如果没有,请附上您使用上述代码创建的示例CSV文件,也许我可以看到出错了。

Try opening the CSV file using a text editor like Notepad+. Select in the Encoding menu UTF8. You should be seeing the correct characters now. If not, please attach an example CSV file you created with the above code, maybe I can see what goes wrong.

这篇关于如何写阿拉伯语,希伯来语到CSV文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆