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

Sending requests with Chinese characters using curl will fail:Invalid UTF-8 middle byte 0xce #4858

Open
1 task
leevin101 opened this issue Mar 11, 2024 · 2 comments

Comments

@leevin101
Copy link

leevin101 commented Mar 11, 2024

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
    32-bit and 64-bit most of release with this problem:
    PortableGit-2.41.0-rc0-32-bit
    PortableGit-2.42.0.2-32-bit
    PortableGit-2.33.1-64-bit
    Git-2.32.0-rc3-64-bit
$ git --version --build-options

** 
git version 2.33.0.windows.2
cpu: x86_64
built from commit: 8735530946cced809cc6cc4c2ca3b078cdb3dfc8
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
**

  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?

windows 10 64-bit

$ cmd.exe /c ver

** Microsoft Windows [版本 10.0.19045.4046] **
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: Notepad++
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Core
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Enabled
Enable FSMonitor: Enabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

** insert your response here **

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

** when use curl comman with Chinese charter,will response with exception **

curl 'http://192.168.56.1:9200/_xpack/sql'  -H 'Content-Type: application/json' -d'{"query":"select * from test where name ='\''张三'\'' "}'

  • What did you expect to occur after running these commands?
{"columns":[{"name":"name","type":"keyword"},{"name":"create_time","type":"keyword"}],"rows":[["张三","2023-06-05 13:37:45"]
]}
  • What actually happened instead?
{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[1:10] [sql/query] failed to parse field [query]"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[1:10] [sql/query] failed to parse field [query]",
    "caused_by" : {
      "type" : "json_parse_exception",
      "reason" : "Invalid UTF-8 middle byte 0xce\n at [Source: (org.elasticsearch.common.io.stream.InputStreamStreamInput); line: 1, column: 87]"
    }
  },
  "status" : 400
}
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

NO

@dscho
Copy link
Member

dscho commented Mar 11, 2024

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

** when use curl comman with Chinese charter,will response with exception **

Sure, but that was not the question. The question was Bash or CMD or PowerShell or other.

Also keep in mind that curl is not exactly within Git for Windows' area of support.

Having said that, you may need to set LC_CTYPE=C.UTF-8 or something similar to make that command work correctly; Unlike Git for Windows, the curl.exe does not assume UTF-8 encoding in its input.

@leevin101
Copy link
Author

thanks for your reply.
But I found that a few curl. exe versions with the word "Unicode" in the Feature can successfully execute.
image

image

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

2 participants