Unable to translate bytes [FC] at index 35 from specified code page to Unicode

前端 未结 4 507
你的背包
你的背包 2021-01-02 06:56

I\'m trying to send an object like this to my REST API(built with asp net core)

{
    \"firstName\":\"tersü\",
    \"lastName\":\"asda\"
}

4条回答
  •  醉话见心
    2021-01-02 07:10

    You are sending your string encoded in utf-16, but telling (in the Content-Type header's charset) it is utf-8.

    The bytes for tersü in utf-8 are:

    74,65,72,73,C3,BC
    

    However tersü (in utf-16) contains the bytes (notice the FC there):

    74,0,65,0,72,0,73,0,FC,0
    

    (Check it in this fiddle)

    So it just can't understand it. So either convert your string to utf-8 in your client before sending it, or set the Content-Type charset to utf-16 .

提交回复
热议问题