Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible unicode handling #137

Closed
taowen opened this issue Jul 18, 2017 · 1 comment
Closed

incompatible unicode handling #137

taowen opened this issue Jul 18, 2017 · 1 comment

Comments

@taowen
Copy link
Contributor

taowen commented Jul 18, 2017

package main

import (
	"encoding/json"
	"log"
	"reflect"

	"github.com/json-iterator/go"
)

func test(s string) {
	var err1, err2 error
	var v1, v2 interface{}
	log.Printf("testing: %q", s)
	err1 = jsoniter.Unmarshal([]byte(s), &v1)
	err2 = json.Unmarshal([]byte(s), &v2)
	if err1 != nil && err2 == nil {
		log.Printf("jsoniter return error but encoding/json not return error: %v", err1)
	} else if err1 == nil && err2 != nil {
		log.Printf("jsoniter not return error but encoding/json return error: %v", err2)
	} else if err1 == nil && err2 == nil && !reflect.DeepEqual(v1, v2) {
		log.Printf("there are different between jsoniter and encoding/json: %v, %v", v1, v2)
	}
}

func main() {
	test(`"\uD83D"`)
	test(`"\U0001f64f"`)
        test(`"\uDEADBEEF"`)
}

reference: gin-gonic/gin#1026

@taowen
Copy link
Contributor Author

taowen commented Jul 18, 2017

fixed

@taowen taowen closed this as completed Jul 18, 2017
taowen added a commit that referenced this issue Jul 18, 2017
zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant