[已解决]双引号内的双引号 [英] [SOLVED] the double quote inside a double quote

查看:134
本文介绍了[已解决]双引号内的双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[已解决:好的,它可能尚未完全解决,但已在正确的文章下重新发布了]

我有一个文本文件,其中的行是"xxx"xx" xxxx条件.

文本文件为;"当csv阅读器去按以下方式阅读此行时分隔

"123344";"0897778";"977686"; "xxx" xxx"xxx" ;"1231231";"12312";"

在粗体处,它给出异常"MalformedCsvException",并说csv是currptes或某些东西.

我要解决的问题是在csvreader.cs
中的方法中 在ReadField()
AT

[Solved: ok, it may not have been completely solved, but it was re-posted under the correct article]

I have a text file in which at the line where is a "xxx "xx" xxxx" condition.

the text file is ";" seprated when the csv reader goes to read this line as follows

"123344";"0897778";"977686";"xxx "xxx" xxx";"1231231";"12312";""

at the bold thing it gives an exception "MalformedCsvException" and says csv is currptes or some thing.

what i was trying to solve this problem is in the method in the csvreader.cs
at ReadField()
AT

Label_03F3:
                while (num5 < this._bufferLength)
                {
                    if (_nextFieldStart + 1 == 41 || _nextFieldStart + 1==42)
                    {
                    }
                    char ch2 = this._buffer[num5];
                    if (flag2)
                    {
                        flag2 = false;
                        num4 = num5;
                    }
                    else if ((ch2 == this._escape) && (((this._escape != this._quote) || (((num5 + 1) < this._bufferLength) && (this._buffer[num5 + 1] == this._quote))) || (((num5 + 1) == this._bufferLength) && (this._reader.Peek() == this._quote))))
                    {
                        if (!discardValue)
                        {
                            str = str + new string(this._buffer, num4, num5 - num4);
                        }
                        flag2 = true;
                    }
                    //else if (ch2 == this._quote && (((num5 + 1) < this._bufferLength) && (this._reader.Peek() != this._quote)))//here i need to add condition of 
                    //{
                    //    //if ((ch2 == this._quote) && (this._buffer[num5 + 1] == this._delimiter))
                    //    //{
                    //    //    flag = false;
                    //    //    break;
                    //    //}
                    //    //else if ((ch2 == this._quote) && (this._buffer[num5 + 1] != this._quote) && (this._buffer[num5 + 1] != this._delimiter))//insted of _quote check a character or space
                    //    //{
                    //    //    flag = false;
                            
                    //    //}
                    //    //else
                    //    //{
                    //        //flag = false;
                    //       // break;
                    //    //}
                        
                    //}

                    //else if ((ch2 == this._quote) && (this._buffer[num5 + 1] == this._delimiter))                      
                    //{
                    //    flag = false;
                    //    break;
                    //}
                    else if (ch2 == this._quote) 
                    {
                        flag = false;
                        break;
                    }
                    num5++;
                }



我正在尝试解决它,但提出了增加的申请数量.

我希望您能在这种情况下为我提供帮助

[edit]添加了用于格式化的代码块[/edit]



i was trying to solve it but it come up with increas of filed count.

i Hope You can help me in this case

[edit]Code block added for formatting[/edit]

推荐答案

我是否正确,因为这是关于CSV阅读器文章的?
如果是这样,请不要在快速解答"下发布该文章-如果您从某篇文章中获得了代码,则该文章底部将出现一个新消息"按钮,这将导致向作者发送电子邮件.然后会通知他们您希望与他们交谈.
将其发布到此处依赖于他们的下落"并意识到它是针对他们的.
Am I right in assuming that this is about a CSV reader article?
If so, don''t post this under Quick Answers - if you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.


这篇关于[已解决]双引号内的双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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