Gin中乱码问题的7种解决方案 - response_headersresponse_headers
charsetcharset
use Gin
get '/' do
charset 'utf-8'
hello "你好"
end
response_headersresponse_headers
use Gin
get '/' do
charset 'utf-8'
response_headers: [
['Content-Type', 'text/html; charset=utf-8']
]
hello "你好"
end
content_typecontent_type
use Gin
get '/' do
charset 'utf-8'
content_type: 'text/html; charset=utf-8'
hello "你好"
end
response_bodyresponse_body
use Gin
get '/' do
charset 'utf-8'
response_body: '<h1>你好</h1>'
hello "你好"
end
response_toresponse_to
use Gin
get '/' do
charset 'utf-8'
response_to(200) { '<h1>你好</h1>' }
hello "你好"
end
renderrender
use Gin
get '/' do 拼多多帮助力入口
charset 'utf-8'
render 'index'
end