• <bdo id='BPfCM'></bdo><ul id='BPfCM'></ul>
      1. <legend id='BPfCM'><style id='BPfCM'><dir id='BPfCM'><q id='BPfCM'></q></dir></style></legend>

        <tfoot id='BPfCM'></tfoot>

      2. <small id='BPfCM'></small><noframes id='BPfCM'>

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

        如何使用 HTTP 标头发送非英文 unicode 字符串?

        时间:2023-06-11

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

          1. <legend id='20lxy'><style id='20lxy'><dir id='20lxy'><q id='20lxy'></q></dir></style></legend>
              <bdo id='20lxy'></bdo><ul id='20lxy'></ul>
                <tbody id='20lxy'></tbody>

              <tfoot id='20lxy'></tfoot>

                <small id='20lxy'></small><noframes id='20lxy'>

                • 本文介绍了如何使用 HTTP 标头发送非英文 unicode 字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 HTTP 相关问题的新手.我的问题是在 iOS 开发中,我想使用 HTTP Header 发送一个字符串,所以我使用的是:

                  I am novice to HTTP related matters. My question is in iOS development, I would like to send a string using HTTP Header, so I'm using:

                  [httpRequest setValue:@"nonEnglishString" forHTTPHeaderField:@"customHeader"];
                  

                  接收服务器是 Python(Google App Engine),将 db 模型中的字符串值保存为 StringProperty 使用:

                  The receiving server is Python(Google App Engine), saving the string value in the db model as StringProperty using:

                  dataEntityInstance.nonEnglishString = unicode(self.request.headers.get('customHeader')
                  

                  但是,问题是当我尝试发送像韩语这样的非英语字符串时,它会像这样保存在 HTTP 标头中:

                  However, the problem is when I try to send non-English string like Korean, it's saved in HTTP header like this:

                  Customheader = "Uc8fcUba39Uc774 Uc6b4Ub2e4";
                  

                  当它被 Google App Engine 接收并保存在 DataStore 中时,它变为:

                  and when it's received by Google App Engine and saved in DataStore, it's changed to be like:

                  ??? ??
                  

                  好像找不到 unicode 值的正确字符.

                  as if it can't find the proper characters for the unicode value.

                  是否不能或不允许使用 HTTP Header 发送非英文字符串?

                  如果我的 iOS 只使用 setHTTPBody,它可以传输非英文字符串并正确保存到 App Engine 的 DataStore.

                  If my iOS uses just setHTTPBody, it can transfer non-English strings and save to App Engine's DataStore properly.

                  [httpRequest setHTTPBody:[httpBody dataUsingEncoding:NSUTF8StringEncoding]];
                  

                  但我只是找不到使用 HTTP 标头实现相同目标的正确方法,就像 Foursquare 等许多 API 所做的那样,并将字符串以适当的形式保存在基于 Python 的 Google App Engine 的 DataStore 中

                  But I just can't find the right way to achieve same goal using HTTP Headers, like what many APIs like Foursquare's do and saving the strings in the proper forms in Python based Google App Engine's DataStore

                  推荐答案

                  使用 HTTP Header 发送非英文字符串是不可能或不允许的吗?

                  Is it not POSSIBLE or ALLOWED to send non-English string using HTTP Header?

                  根据 HTTP 标准,将非 ISO-8859-1 字符直接放入 HTTP 标头是不可能的.这为您提供了 ASCII(英语"?)字符以及常见的西欧变音符号.

                  It's not possible as per HTTP standards to put non-ISO-8859-1 characters directly in an HTTP header. That gives you ASCII ("English"?) characters plus common Western European diacriticals.

                  但是在实践中,您甚至不能使用扩展的 ISO-8859-1 字符,因为服务器和浏览器在如何处理标头中的非 ASCII 字符方面并不一致.Safari 采用 RFC2616 字样并将高字节视为 ISO-8859-1 字符;Mozilla 采用 UTF-16 代码单元低字节,类似但更奇怪;Opera 和 Chrome 从 UTF-8 解码;IE 使用本地系统代码页.

                  However in practice you can't even use the extended ISO-8859-1 characters, because servers and browsers don't agree on what to do with non-ASCII characters in headers. Safari takes RFC2616 at its word and treats high bytes as ISO-8859-1 characters; Mozilla takes UTF-16 code unit low bytes, which is similar but weirder; Opera and Chrome decode from UTF-8; IE uses the local system code page.

                  所以实际上,您可以在 HTTP 标头中输入的只是没有控制代码的简单 ASCII.如果你想要更多,你必须想出一个编码方案(例如 UTF-8+base64).RFC2616 标准建议将 RFC2047 编码词作为一种标准的编码形式,但考虑到 RFC2047 本身何时允许使用它们的定义,这是没有意义的,并且没有任何支持.

                  So in reality all you can put in an HTTP header is simple ASCII with no control codes. If you want anything more, you'll have to come up with an encoding scheme (eg UTF-8+base64). The RFC2616 standard suggests RFC2047 encoded-words as a standard form of encoding, but this makes no sense given the definitions of when they are allowable in RFC2047 itself, and nothing supports it.

                  这篇关于如何使用 HTTP 标头发送非英文 unicode 字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在嵌入式 UIWebView 中指定 HTTP 引用 下一篇:如何在 webView 的 url 中发送引用请求

                  相关文章

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

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

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