Fix unicode decoding
This commit is contained in:
@@ -2,8 +2,8 @@ package toml
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pelletier/go-toml/v2/internal/ast"
|
"github.com/pelletier/go-toml/v2/internal/ast"
|
||||||
@@ -677,11 +677,11 @@ func hexToString(b []byte, length int) (string, error) {
|
|||||||
return "", fmt.Errorf("unicode point needs %d hex characters", length)
|
return "", fmt.Errorf("unicode point needs %d hex characters", length)
|
||||||
}
|
}
|
||||||
// TODO: slow
|
// TODO: slow
|
||||||
b, err := hex.DecodeString(string(b[:length]))
|
intcode, err := strconv.ParseInt(string(b[:length]), 16, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return string(b), nil
|
return string(rune(intcode)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parseWhitespace(b []byte) []byte {
|
func (p *parser) parseWhitespace(b []byte) []byte {
|
||||||
|
|||||||
Reference in New Issue
Block a user