Example #1
0
func Example_writer() {
	w := yacr.DefaultWriter(os.Stdout)
	for _, field := range []string{"c1", "c\"2", "c\n3", "c,4"} {
		if !w.WriteString(field) {
			break
		}
	}
	w.Flush()
	if err := w.Err(); err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
	// Output: c1,"c""2","c
	// 3","c,4"
}
Example #2
0
File: main.go Project: gwenn/yacr
func Fuzz(data []byte) int {
	r := yacr.DefaultReader(bytes.NewReader(data))
	for r.Scan() {
		r.Text()
		if r.EndOfRecord() {
			break
		}
	}
	err := r.Err()
	if err != nil {
		return 0
	}

	// Double quotes are not preserved when not strictly needed
	w := yacr.DefaultWriter(ioutil.Discard)
	w.Write(data)
	err = w.Err()
	if err != nil {
		return 0
	}
	return 1
}