<tfoot id='RQuAq'></tfoot>

  1. <i id='RQuAq'><tr id='RQuAq'><dt id='RQuAq'><q id='RQuAq'><span id='RQuAq'><b id='RQuAq'><form id='RQuAq'><ins id='RQuAq'></ins><ul id='RQuAq'></ul><sub id='RQuAq'></sub></form><legend id='RQuAq'></legend><bdo id='RQuAq'><pre id='RQuAq'><center id='RQuAq'></center></pre></bdo></b><th id='RQuAq'></th></span></q></dt></tr></i><div id='RQuAq'><tfoot id='RQuAq'></tfoot><dl id='RQuAq'><fieldset id='RQuAq'></fieldset></dl></div>
    • <bdo id='RQuAq'></bdo><ul id='RQuAq'></ul>

    <small id='RQuAq'></small><noframes id='RQuAq'>

    <legend id='RQuAq'><style id='RQuAq'><dir id='RQuAq'><q id='RQuAq'></q></dir></style></legend>

      无法将索引 35 处的字节 [FC] 从指定代码页转换为 Unicode

      时间:2023-07-12

      <small id='kyoXw'></small><noframes id='kyoXw'>

        <tbody id='kyoXw'></tbody>
        <bdo id='kyoXw'></bdo><ul id='kyoXw'></ul>
        <tfoot id='kyoXw'></tfoot>
          • <legend id='kyoXw'><style id='kyoXw'><dir id='kyoXw'><q id='kyoXw'></q></dir></style></legend>

              • <i id='kyoXw'><tr id='kyoXw'><dt id='kyoXw'><q id='kyoXw'><span id='kyoXw'><b id='kyoXw'><form id='kyoXw'><ins id='kyoXw'></ins><ul id='kyoXw'></ul><sub id='kyoXw'></sub></form><legend id='kyoXw'></legend><bdo id='kyoXw'><pre id='kyoXw'><center id='kyoXw'></center></pre></bdo></b><th id='kyoXw'></th></span></q></dt></tr></i><div id='kyoXw'><tfoot id='kyoXw'></tfoot><dl id='kyoXw'><fieldset id='kyoXw'></fieldset></dl></div>

              • 本文介绍了无法将索引 35 处的字节 [FC] 从指定代码页转换为 Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试将这样的对象发送到我的 REST API(使用 asp net core 构建)

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

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

                这就是 SoapUI 中标题的外观:

                And this is how the headers form SoapUI look:

                 Accept-Encoding: gzip,deflate
                Content-Type: application/json:charset=UTF-16
                Host: localhost:4004
                Connection: Keep-Alive
                User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
                

                但是,我的 actionContext.ModelState 始终无效,因为它不能与元音变音一起使用.例外情况如下:

                However, my actionContext.ModelState is always invalid because it can not work with the umlaute. The exception is the following:

                无法将索引 35 处的字节 [FC] 从指定代码页转换为统一码

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

                如果有任何帮助,方法签名如下所示:

                If it's any help, the method signature looks like this:

                [ValidateUserData]
                public async Task<IActionResult> Update(string userId, [FromBody] UpdateUserRequest updateRequest)
                

                基本上代码从不重复

                if (!actionContext.ModelState.IsValid)
                {
                    actionContext.Result = new BadRequestObjectResult(actionContext.ModelState);
                }
                

                [ValidateUserData] 属性中

                我在这里错过了什么?

                推荐答案

                你正在发送用 utf-16 编码的字符串,但是告诉(在 Content-Type标头的字符集)它是 utf-8.

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

                utf-8tersü的字节为:

                74,65,72,73,C3,BC
                

                但是 tersü(在 utf-16 中)包含字节(注意那里的 FC):

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

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

                (检查它in this fiddle)

                所以它只是无法理解它.因此,要么在发送之前将您的字符串转换为客户端中的 utf-8,要么将 Content-Type 字符集设置为 utf-16.

                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 .

                这篇关于无法将索引 35 处的字节 [FC] 从指定代码页转换为 Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:从 ASP.Net Core 中的 wwwroot/images 获取图像 下一篇:在 ASP.NET Core 中使用防伪 cookie,但使用非默认 CookieName

                相关文章

                1. <tfoot id='L3wzn'></tfoot><legend id='L3wzn'><style id='L3wzn'><dir id='L3wzn'><q id='L3wzn'></q></dir></style></legend>
                  <i id='L3wzn'><tr id='L3wzn'><dt id='L3wzn'><q id='L3wzn'><span id='L3wzn'><b id='L3wzn'><form id='L3wzn'><ins id='L3wzn'></ins><ul id='L3wzn'></ul><sub id='L3wzn'></sub></form><legend id='L3wzn'></legend><bdo id='L3wzn'><pre id='L3wzn'><center id='L3wzn'></center></pre></bdo></b><th id='L3wzn'></th></span></q></dt></tr></i><div id='L3wzn'><tfoot id='L3wzn'></tfoot><dl id='L3wzn'><fieldset id='L3wzn'></fieldset></dl></div>
                  1. <small id='L3wzn'></small><noframes id='L3wzn'>

                      <bdo id='L3wzn'></bdo><ul id='L3wzn'></ul>