When I send the request, the emoji become gibberish.
I believe that encoding it would fix. For instance, this
He is \uD83D\uDE00</p> will work.
Does anyone know how can encode this? or if you know anything else I can do to get this working?
Thanks in advance
lutzhorn
(Lutz Horn)
March 23, 2020, 12:07pm
2
Please show us the exact client code that makes this request.
How do you know your code does not work? What do you expect?
payloadB, err := json.Marshal(payload)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", uri, bytes.NewReader(payloadB))
req.SetBasicAuth(username, password)
req.Header.Set("Content-Type", "application/json")
I want to receive the emoji instead of this Γ°ΒΒΒ
lutzhorn
(Lutz Horn)
March 23, 2020, 2:01pm
4
The snippet youβve posted does not contain the emoji. What exactly is payload
?
This is the payload:
{ "string": "<p>Barry π</p>"}
lutzhorn
(Lutz Horn)
March 23, 2020, 2:29pm
6
Not the payload but the exact content of payload
in this line:
payloadB, err := json.Marshal(payload)
It is very hard to help you if you donβt provide the information necessary to understand and reproduce your problem.
This the data. Sorry for the delay and for not providing this before hand
type Data struct {
TextData string `json:"text"`
}
s := "{<p>Barry π π</p>}"
payload := TextData{
TextData: s
}
payloadB, err := json.Marshal(payload)
1 Like
lutzhorn
(Lutz Horn)
March 23, 2020, 2:49pm
8
So far I canβt reproduce your problem. Consider this: https://play.golang.org/p/G59ENK7WxhV
The call of json.Unmarshal
with the result of json.Marshal
as the input returns the expected TextData
. The emoji is fine.
So please show us what you do with the encoded payloadB
. How do you post it? How do you know that the server you post it to receives gibberish?
When i send the request to my end point, I handle the request and render it on html page.
and the render looks like this <p>Barry Γ°ΒΒΒ</p>
so even the p tag is not rendered as it should be.
system
(system)
Closed
June 21, 2020, 2:58pm
10
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.