Skip to content

Commit

Permalink
fix(ptst): Corrige como lida com carateres escapados
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfeitosa committed Feb 20, 2024
1 parent 379985e commit 5e44251
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ptst/texto.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ptst

import (
"fmt"
"strconv"
"strings"
"unicode/utf8"
)
Expand All @@ -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
Expand Down

0 comments on commit 5e44251

Please sign in to comment.