mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[GH-ISSUE #5367] [bug]: Support for GB2312/GBK Character Encoding in JSON Responses #2054
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#2054
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tossp on GitHub (Sep 2, 2025).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/5367
Is there an existing issue for this?
Platform
Web App
Browser
Chrome
Operating System
Windows
Bug Description
Currently, Hoppscotch automatically decodes response bodies based on the charset specified in the
Content-Typeheader, such ascharset=utf-8. However, when an API responds withapplication/json; charset=gb2312,gbk, or other non-UTF8 encodings, Hoppscotch does not correctly decode the response body, resulting in unreadable or garbled content.Problem
Some APIs and legacy systems still use character encodings other than UTF-8 for their JSON responses. When testing these APIs in Hoppscotch, users cannot properly read or parse the response content due to the lack of support for these encodings. This can affect developers working with a variety of systems and languages.
Proposed Solution
charsetparameter in theContent-Typeheader and decode the response body accordingly.Benefits
References
Thank you for considering this feature request!
Deployment Type
Self-hosted (on-prem deployment)
Version
2025.8.0
@Jatkingmodern commented on GitHub (Oct 1, 2025):
Hoppscotch currently decodes response bodies using UTF-8 (or relies on the browser default). When a response contains a Content-Type header with a charset= parameter that is non-UTF8 (e.g. charset=gb2312, gbk, iso-8859-1), the response body is not decoded correctly and appears garbled.
Goal: detect charset in Content-Type, decode the raw bytes using that character set, and present readable content. Provide a fallback/manual override when automatic detection fails.
High-level solution options
Frontend (browser) approaches
Use the Encoding Standard / TextDecoder
with the provided label (e.g. new TextDecoder('gbk')) to decode an ArrayBuffer. Modern browsers implement a large set of legacy encodings. This is the preferred, zero-deps approach if the user's browser supports the requested label.
If the browser does not support the requested encoding, fall back to a JS/WASM decoder:
encoding.js (older, CPU heavy, but pure JS; supports many encodings).
encoding_rs compiled to WASM (or use encoding_rs_wasm) — faster and more robust.
Or a bundled iconv-lite-like solution compiled for the browser (more complex).
Always allow the user to manually choose the encoding from a drop-down in the response panel (UTF-8, GBK, GB2312, ISO-8859-1, SHIFT_JIS, WINDOWS-1252, etc.) and re-decode on demand.
Server-side:
If Hoppscotch has a server proxy (or in a self-hosted deployment), you can decode server-side using iconv-lite and return a UTF-8 body to client. This simplifies browser support at the expense of extra server processing and possibly privacy concerns (responses routed through server).
Recommendation: implement frontend decoding first using TextDecoder + fallback to WASM/JS decoder, and add manual override.