mirror of
https://github.com/octopusYan/dayz-mod-translator.git
synced 2024-12-29 20:36:42 +08:00
fix: csv连续双引号处理
This commit is contained in:
parent
904f37a15b
commit
0c9052216b
@ -38,6 +38,10 @@ public final class CsvParser extends ComputeIter<CsvRow> implements Closeable, S
|
|||||||
* 是否在引号包装内
|
* 是否在引号包装内
|
||||||
*/
|
*/
|
||||||
private boolean inQuotes;
|
private boolean inQuotes;
|
||||||
|
/**
|
||||||
|
* 连续双引号计数
|
||||||
|
*/
|
||||||
|
private int continuousCount = 0;
|
||||||
/**
|
/**
|
||||||
* 当前读取字段
|
* 当前读取字段
|
||||||
*/
|
*/
|
||||||
@ -257,9 +261,15 @@ public final class CsvParser extends ComputeIter<CsvRow> implements Closeable, S
|
|||||||
if (inQuotes) {
|
if (inQuotes) {
|
||||||
//引号内,作为内容,直到引号结束
|
//引号内,作为内容,直到引号结束
|
||||||
if (c == config.textDelimiter) {
|
if (c == config.textDelimiter) {
|
||||||
// End of quoted text
|
if(buf.canRead(1) && buf.read(1) == CharUtil.DOUBLE_QUOTES) {
|
||||||
inQuotes = false;
|
continuousCount++;
|
||||||
|
} else if(continuousCount != 0 && (continuousCount + 1) % 2 == 0) {
|
||||||
|
continuousCount = 0;
|
||||||
} else {
|
} else {
|
||||||
|
inQuotes = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(continuousCount != 0) continuousCount = 0;
|
||||||
// 字段内容中新行
|
// 字段内容中新行
|
||||||
if (isLineEnd(c, preChar)) {
|
if (isLineEnd(c, preChar)) {
|
||||||
inQuotesLineCount++;
|
inQuotesLineCount++;
|
||||||
@ -450,6 +460,14 @@ public final class CsvParser extends ComputeIter<CsvRow> implements Closeable, S
|
|||||||
return this.buf[this.position++];
|
return this.buf[this.position++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean canRead(int position) {
|
||||||
|
return (this.position + position - 1) < limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
char read(int position) {
|
||||||
|
return this.buf[this.position + position - 1];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标记位置记为下次读取位置
|
* 标记位置记为下次读取位置
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user