mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Merge branch 'main' of github.com:johnkerl/miller
This commit is contained in:
commit
a96b1cc052
5 changed files with 16 additions and 7 deletions
|
|
@ -46,22 +46,21 @@ func TSVDecodeField(input string) string {
|
|||
// TSVEncodeField is for the TSV record-writer.
|
||||
func TSVEncodeField(input string) string {
|
||||
var buffer bytes.Buffer
|
||||
for i := range input {
|
||||
c := input[i]
|
||||
if c == '\\' {
|
||||
for _, r := range input {
|
||||
if r == '\\' {
|
||||
buffer.WriteByte('\\')
|
||||
buffer.WriteByte('\\')
|
||||
} else if c == '\n' {
|
||||
} else if r == '\n' {
|
||||
buffer.WriteByte('\\')
|
||||
buffer.WriteByte('n')
|
||||
} else if c == '\r' {
|
||||
} else if r == '\r' {
|
||||
buffer.WriteByte('\\')
|
||||
buffer.WriteByte('r')
|
||||
} else if c == '\t' {
|
||||
} else if r == '\t' {
|
||||
buffer.WriteByte('\\')
|
||||
buffer.WriteByte('t')
|
||||
} else {
|
||||
buffer.WriteByte(c)
|
||||
buffer.WriteRune(r)
|
||||
}
|
||||
}
|
||||
return buffer.String()
|
||||
|
|
|
|||
1
test/cases/io-spec-tsv/0003/cmd
Normal file
1
test/cases/io-spec-tsv/0003/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --ijson --otsv cat ${CASEDIR}/data.json
|
||||
7
test/cases/io-spec-tsv/0003/data.json
Normal file
7
test/cases/io-spec-tsv/0003/data.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
{
|
||||
"alpha": "alpha",
|
||||
"βετα": "βετα",
|
||||
"гамма": "гамма"
|
||||
}
|
||||
]
|
||||
0
test/cases/io-spec-tsv/0003/experr
Normal file
0
test/cases/io-spec-tsv/0003/experr
Normal file
2
test/cases/io-spec-tsv/0003/expout
Normal file
2
test/cases/io-spec-tsv/0003/expout
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
alpha βετα гамма
|
||||
alpha βετα гамма
|
||||
Loading…
Add table
Add a link
Reference in a new issue