mistweaverco / kulala.nvim

A minimal 🤏 HTTP-client 🐼 interface 🖥️ for Neovim ❤️.
https://kulala.mwco.app
MIT License
581 stars 27 forks source link

[cURL for Windows Issue] Do not support Chinese? #147

Closed iamxiaojianzheng closed 4 weeks ago

iamxiaojianzheng commented 1 month ago
POST https://jsonplaceholder.typicode.com/posts
Content-Type: application/json; charset=utf-8

{"title":"中文"}

Chinese cannot be displayed properly

{
  "title": "����",
  "id": 101
}

And when the post request parameter contains Chinese, it will be garbled.

image

gorillamoe commented 1 month ago

Seems to work for me, at least when using httpbin.org.

image

POST https://httpbin.org/post HTTP/1.1
Content-Type: application/json; charset=utf-8

{"title":"中文"}

Server responds with:

{
  "args": {},
  "data": "{\"title\":\"中文\"}",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Content-Length": "18",
    "Content-Type": "application/json; charset=utf-8",
    "Host": "httpbin.org",
    "User-Agent": "kulala.nvim/3.2.2",
    "X-Amzn-Trace-Id": "Root=1-66c0aedb-4fef252c64c025b71e58a522"
  },
  "json": {
    "title": "中文"
  },
  "origin": "80.187.119.86",
  "url": "https://httpbin.org/post"
}
gorillamoe commented 1 month ago

Variables also seem to work fine.

GET https://httpbin.org/get?foo=中文 HTTP/1.1

Server responds with:

{
  "args": {
    "foo": "中文"
  },
  "headers": {
    "Accept": "*/*",
    "Host": "httpbin.org",
    "User-Agent": "kulala.nvim/3.2.2",
    "X-Amzn-Trace-Id": "Root=1-66c0afaa-7b981b37247eabb4728b0e13"
  },
  "origin": "80.187.119.86",
  "url": "https://httpbin.org/get?foo=中文"
}
iamxiaojianzheng commented 1 month ago

Maybe it has something to do with the shell?

I tried gitbash, powershell, cmd.

The following three results are obtained.

gitbash image

powershell image

cmd image

iamxiaojianzheng commented 1 month ago

When variables are used, all three results are consistent.

image

iamxiaojianzheng commented 1 month ago

curl version info

curl 8.9.0 (x86_64-w64-mingw32) libcurl/8.9.0 Schannel zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0
Release-Date: 2024-07-24
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL SSPI threadsafe UnixSockets zstd
gorillamoe commented 1 month ago

Maybe it is either the shell or the curl version? Can you try wezterm?

gorillamoe commented 1 month ago

Seems to be an issue with curl for windows? https://github.com/curl/curl/discussions/10446

You can always try the :lua require("kulala").copy() command which should try to copy a curl command to your clipboard.

There you might add some -vvv flags to debug what curl is doing.

iamxiaojianzheng commented 1 month ago

It's a compatibility issue with curl on Windows.

I found a solution. Is it possible to do this in a configuration way in kulala?

echo -en "$(curl -s -X "POST" --data "{""title"":""中文""}" -H "content-type:application/json; charset=utf-8" --http1.1 -A "kulala.nvim/3.2.2" "https://httpbin.org/post")"
gorillamoe commented 1 month ago

I have to think about a workaround for that, but have you tried this? https://user-images.githubusercontent.com/2276718/227071658-2c25848f-fd69-444a-a95b-0e77cc2f5437.png

iamxiaojianzheng commented 1 month ago

This method, I have tried. But it still can't be solved.

Only slightly effective in gitbash

image

iamxiaojianzheng commented 1 month ago

This method, I have tried. But it still can't be solved.

Only slightly effective in gitbash

image

Compared to before

image

gorillamoe commented 1 month ago

Someone seems to have managed it with cmder:

iamxiaojianzheng commented 1 month ago

I have to think about a workaround for that, but have you tried this? https://user-images.githubusercontent.com/2276718/227071658-2c25848f-fd69-444a-a95b-0e77cc2f5437.png

When I enable this, I have no problem accessing this interface.

image

But access to this interface, the result is still Unicode.

image

gorillamoe commented 1 month ago

Someone seems to have managed it with cmder:

I tried this by myself on windows and it's working.