cURL – chcp

Well I joined a local company last week and had to handle a GBK chars issue when I started to write my RestAPI test cases.

My cURL result contained Chinese chars.

活动代码页: 936

C:\Windows\system32>curl -i –header “Accept:application/json” -X GET -b D:\cook
ie.txt http://xxx:8081/api/member/xxx
HTTP/1.1 401
Server: nginx/1.12.0
Date: Fri, 17 Nov 2017 08:54:27 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Set-Cookie: SESSION=;Max-Age=0;path=/;HttpOnly

{“timestamp”:1510908867367,”status”:401,”error”:”Unauthorized”,”message”:”姝ょ敤
鎴峰湪鍏朵粬鍦版柟鐧诲綍”,”path”:”/api/member/xxx”}
C:\Windows\system32>curl -i –header “Accept:application/json” -X GET -b D:\cook
ie.txt http://xxx:8081/api/message/xxxx

Had to do,

  1. chcp 65001 (set it UTF-8)
  2. and then set the console property.

console_property.PNG