goprotobuf: Be more liberal in text format string parsing.

Also, a minor style tweak in CompactTextString.

R=r
CC=golang-dev
http://codereview.appspot.com/5876069
diff --git a/proto/text_parser.go b/proto/text_parser.go
index e6cb44d..2124308 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -38,6 +38,7 @@
 	"fmt"
 	"reflect"
 	"strconv"
+	"strings"
 )
 
 type ParseError struct {
@@ -168,8 +169,7 @@
 			p.errorf("unmatched quote")
 			return
 		}
-		// TODO: Should be UnquoteC.
-		unq, err := strconv.Unquote(p.s[0 : i+1])
+		unq, err := unquoteC(p.s[0 : i+1])
 		if err != nil {
 			p.errorf("invalid quoted string %v", p.s[0:i+1])
 			return
@@ -190,6 +190,14 @@
 	p.offset += len(p.cur.value)
 }
 
+func unquoteC(s string) (string, error) {
+	// A notable divergence between quoted string literals in Go
+	// and what is acceptable for text format protocol buffers:
+	// the former considers \' invalid, but the latter considers it valid.
+	s = strings.Replace(s, `\'`, "'", -1)
+	return strconv.Unquote(s)
+}
+
 // Back off the parser by one token. Can only be done between calls to next().
 // It makes the next advance() a no-op.
 func (p *textParser) back() { p.backed = true }