From 5e44251dede0eeb46bc6ebcc49977cc8901384cc Mon Sep 17 00:00:00 2001 From: natanfeitosa Date: Tue, 20 Feb 2024 17:14:26 -0300 Subject: [PATCH] fix(ptst): Corrige como lida com carateres escapados --- ptst/texto.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ptst/texto.go b/ptst/texto.go index e032dbc..0041f0c 100644 --- a/ptst/texto.go +++ b/ptst/texto.go @@ -2,6 +2,7 @@ package ptst import ( "fmt" + "strconv" "strings" "unicode/utf8" ) @@ -22,9 +23,11 @@ func NewTexto(arg any) (Objeto, error) { case nil: return Texto(""), nil case string: - obj = strings.ReplaceAll(obj, "\\n", "\n") - obj = strings.ReplaceAll(obj, "\\r", "\r") - obj = strings.ReplaceAll(obj, "\\t", "\t") + obj, err := strconv.Unquote(`"` + obj + `"`) + if err != nil { + return nil, err + } + return Texto(obj), nil case Texto: return obj, nil