Chinese Encoding mismatch(charset garbling for Chinese)! #21755

Closed
opened 2026-02-21 20:14:10 -05:00 by yindo · 3 comments
Owner

Originally created by @SpencerKD on GitHub (Jan 19, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Deploy the version 1.11.1, Dify node requests the http API and the response of Chinese mismatch

✔️ Expected Behavior

I deployed dify which of the version is 1.11.1, but I countered the problem of charset garbling (for Chinese)

Image

Actual Behavior

No response

Originally created by @SpencerKD on GitHub (Jan 19, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Deploy the version 1.11.1, Dify node requests the http API and the response of Chinese mismatch ### ✔️ Expected Behavior I deployed dify which of the version is 1.11.1, but I countered the problem of charset garbling (for Chinese) <img width="1815" height="363" alt="Image" src="https://github.com/user-attachments/assets/779e8081-17bf-4b3f-af96-abbcfefc9f8d" /> ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 20:14:10 -05:00
yindo closed this issue 2026-02-21 20:14:10 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 19, 2026):

The Chinese charset garbling in Dify API responses is usually caused by encoding mismatches in your Docker environment or missing charset in HTTP response headers. Here’s how you can fix it:

  1. Locale settings in Docker: Make sure all your API containers set LANG and LC_ALL to C.UTF-8 (recent versions switched from en_US.UTF-8 to C.UTF-8 for universal UTF-8 support) and PYTHONIOENCODING to utf-8. You can set these in your Docker Compose or Dockerfile. Example:

    LANG=C.UTF-8
    LC_ALL=C.UTF-8
    PYTHONIOENCODING=utf-8
    

    See the relevant PR and config changes.

  2. Content-Type header in API responses: The backend should set the HTTP header to application/json; charset=utf-8 for all JSON responses. If the header is missing the charset, clients may misinterpret Chinese characters. The fix is to update backend response code (especially in functions like compact_generate_response) to include charset=utf-8 in the Content-Type header. See technical details and code reference.

  3. MySQL database charset: If you use MySQL, check that your database, tables, and connection all use utf8mb4 charset and utf8mb4_unicode_ci collation. Update your Docker/MySQL config and Dify connection string if needed. See troubleshooting steps.

  4. Diagnosing the issue: Check if the garbling appears in the raw API response (browser/network tab or curl) or only in the frontend/UI. If the raw response is correct but the UI is garbled, it’s likely a frontend or client-side decoding issue. If the raw response is already garbled, focus on backend and Docker locale settings.

These steps should resolve most Chinese encoding problems in Dify’s self-hosted Docker setup. If you still see issues, enable debug logs and compare the raw backend response with the frontend display to pinpoint where the encoding breaks.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 19, 2026): <!-- Answer --> The Chinese charset garbling in Dify API responses is usually caused by encoding mismatches in your Docker environment or missing charset in HTTP response headers. Here’s how you can fix it: 1. **Locale settings in Docker**: Make sure all your API containers set `LANG` and `LC_ALL` to `C.UTF-8` (recent versions switched from `en_US.UTF-8` to `C.UTF-8` for universal UTF-8 support) and `PYTHONIOENCODING` to `utf-8`. You can set these in your Docker Compose or Dockerfile. Example: ``` LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONIOENCODING=utf-8 ``` [See the relevant PR and config changes](https://github.com/langgenius/dify/pull/30621). 2. **Content-Type header in API responses**: The backend should set the HTTP header to `application/json; charset=utf-8` for all JSON responses. If the header is missing the charset, clients may misinterpret Chinese characters. The fix is to update backend response code (especially in functions like `compact_generate_response`) to include `charset=utf-8` in the Content-Type header. [See technical details and code reference](https://github.com/langgenius/dify/issues/29528). 3. **MySQL database charset**: If you use MySQL, check that your database, tables, and connection all use `utf8mb4` charset and `utf8mb4_unicode_ci` collation. Update your Docker/MySQL config and Dify connection string if needed. [See troubleshooting steps](https://github.com/langgenius/dify/issues/23054). 4. **Diagnosing the issue**: Check if the garbling appears in the raw API response (browser/network tab or curl) or only in the frontend/UI. If the raw response is correct but the UI is garbled, it’s likely a frontend or client-side decoding issue. If the raw response is already garbled, focus on backend and Docker locale settings. These steps should resolve most Chinese encoding problems in Dify’s self-hosted Docker setup. If you still see issues, enable debug logs and compare the raw backend response with the frontend display to pinpoint where the encoding breaks. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/eb03e5da-0b6b-41d6-a450-d749207a6b37?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/eb03e5da-0b6b-41d6-a450-d749207a6b37?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/eb03e5da-0b6b-41d6-a450-d749207a6b37?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/eb03e5da-0b6b-41d6-a450-d749207a6b37?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/eb03e5da-0b6b-41d6-a450-d749207a6b37?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/eb03e5da-0b6b-41d6-a450-d749207a6b37?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/eb03e5da-0b6b-41d6-a450-d749207a6b37?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20Chinese%20charset%20garbling%20in%20Dify%20API%20responses%20is%20usually%20caused%20by%20encoding%20mismatches%20in%20your%20Docker%20environment%20or%20missing%20charset%20in%20HTTP%20response%20headers.%20Here%E2%80%99s%20how%20you%20can%20fix%20it%3A%0A%0A1.%20%2A%2ALocale%20settings%20in%20Docker%2A%2A%3A%20Make%20sure%20all%20your%20API%20containers%20set%20%60LANG%60%20and%20%60LC_ALL%60%20to%20%60C.UTF-8%60%20%28recent%20versions%20switched%20from%20%60en_US.UTF-8%60%20to%20%60C.UTF-8%60%20for%20universal%20UTF-8%20support%29%20and%20%60PYTHONIOENCODING%60%20to%20%60utf-8%60.%20You%20can%20set%20these%20in%20your%20Docker%20Compose%20or%20Dockerfile.%20Example%3A%0A%20%20%20%60%60%60%0A%20%20%20LANG%3DC.UTF-8%0A%20%20%20LC_ALL%3DC.UTF-8%0A%20%20%20PYTHONIOENCODING%3Dutf-8%0A%20%20%20%60%60%60%0A%20%20%20%5BSee%20the%20relevant%20PR%20and%20config%20changes%5D%28https%3A//github.com/langgenius/dify/pull/30621%29.%0A%0A2.%20%2A%2AContent-Type%20header%20in%20API%20responses%2A%2A%3A%20The%20backend%20should%20set%20the%20HTTP%20header%20to%20%60application/json%3B%20charset%3Dutf-8%60%20for%20all%20JSON%20responses.%20If%20the%20header%20is%20missing%20the%20charset%2C%20clients%20may%20misinterpret%20Chinese%20characters.%20The%20fix%20is%20to%20update%20backend%20response%20code%20%28especially%20in%20functions%20like%20%60compact_generate_response%60%29%20to%20include%20%60charset%3Dutf-8%60%20in%20the%20Content-Type%20header.%20%5BSee%20technical%20details%20and%20code%20reference%5D%28https%3A//github.com/langgenius/dify/issues/29528%29.%0A%0A3.%20%2A%2AMySQL%20database%20charset%2A%2A%3A%20If%20you%20use%20MySQL%2C%20check%20that%20your%20database%2C%20tables%2C%20and%20connection%20all%20use%20%60utf8mb4%60%20charset%20and%20%60utf8mb4_unicode_ci%60%20collation.%20Update%20your%20Docker/MySQL%20config%20and%20Dify%20connection%20string%20if%20needed.%20%5BSee%20troubleshooting%20steps%5D%28https%3A//github.com/langgenius/dify/issues/23054%29.%0A%0A4.%20%2A%2ADiagnosing%20the%20issue%2A%2A%3A%20Check%20if%20the%20garbling%20appears%20in%20the%20raw%20API%20response%20%28browser/network%20tab%20or%20curl%29%20or%20only%20in%20the%20frontend/UI.%20If%20the%20raw%20response%20is%20correct%20but%20the%20UI%20is%20garbled%2C%20it%E2%80%99s%20likely%20a%20frontend%20or%20client-side%20decoding%20issue.%20If%20the%20raw%20response%20is%20already%20garbled%2C%20focus%20on%20backend%20and%20Docker%20locale%20settings.%0A%0AThese%20steps%20should%20resolve%20most%20Chinese%20encoding%20problems%20in%20Dify%E2%80%99s%20self-hosted%20Docker%20setup.%20If%20you%20still%20see%20issues%2C%20enable%20debug%20logs%20and%20compare%20the%20raw%20backend%20response%20with%20the%20frontend%20display%20to%20pinpoint%20where%20the%20encoding%20breaks.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31214)
Author
Owner

@fatelei commented on GitHub (Jan 19, 2026):

Self Checks

  • I have read the Contributing Guide and Language Policy.[x] This is only for bug report, if you would like to ask a question, please head to Discussions.[x] I have searched for existing issues search for existing issues, including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Deploy the version 1.11.1, Dify node requests the http API and the response of Chinese mismatch

✔️ Expected Behavior

I deployed dify which of the version is 1.11.1, but I countered the problem of charset garbling (for Chinese)

Image ### Actual Behavior _No response_

if you use requests, you can

import requests

def foo():
    resp = requests.get("xxx")
    resp.encoding = "utf8"
    return {"results": resp.text}
@fatelei commented on GitHub (Jan 19, 2026): > ### Self Checks > * [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542).[x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general).[x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields. > > ### Dify version > 1.11.1 > > ### Cloud or Self Hosted > Self Hosted (Docker) > > ### Steps to reproduce > Deploy the version 1.11.1, Dify node requests the http API and the response of Chinese mismatch > > ### ✔️ Expected Behavior > I deployed dify which of the version is 1.11.1, but I countered the problem of charset garbling (for Chinese) > > <img alt="Image" width="1815" height="363" src="https://private-user-images.githubusercontent.com/50443358/537426860-779e8081-17bf-4b3f-af96-abbcfefc9f8d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njg4MDY3NTIsIm5iZiI6MTc2ODgwNjQ1MiwicGF0aCI6Ii81MDQ0MzM1OC81Mzc0MjY4NjAtNzc5ZTgwODEtMTdiZi00YjNmLWFmOTYtYWJiY2ZlZmM5ZjhkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAxMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMTE5VDA3MDczMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMwZmQzNTkwMDljY2RkOWY0N2VjM2ZlMjY3N2JlODk5MDVhZDQ0MGM1ODk2NWVkMGQ4NzM0MjUxZDcxY2Q5NDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0ruixknWobZXQbDSxZMiaJWfZSAl2tQyQOl5oemoWvQ"> > ### ❌ Actual Behavior > _No response_ if you use requests, you can ``` import requests def foo(): resp = requests.get("xxx") resp.encoding = "utf8" return {"results": resp.text} ```
Author
Owner

@SpencerKD commented on GitHub (Jan 19, 2026):

Self Checks

  • I have read the Contributing Guide and Language Policy.[x] This is only for bug report, if you would like to ask a question, please head to Discussions.[x] I have searched for existing issues search for existing issues, including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Deploy the version 1.11.1, Dify node requests the http API and the response of Chinese mismatch

✔️ Expected Behavior

I deployed dify which of the version is 1.11.1, but I countered the problem of charset garbling (for Chinese)
Image

Actual Behavior

No response

if you use requests, you can

import requests

def foo():
    resp = requests.get("xxx")
    resp.encoding = "utf8"
    return {"results": resp.text}

No,I used the HTTP node like this

Image
@SpencerKD commented on GitHub (Jan 19, 2026): > > ### Self Checks > > > > > > * [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542).[x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general).[x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields. > > ### Dify version > > 1.11.1 > > ### Cloud or Self Hosted > > Self Hosted (Docker) > > ### Steps to reproduce > > Deploy the version 1.11.1, Dify node requests the http API and the response of Chinese mismatch > > ### ✔️ Expected Behavior > > I deployed dify which of the version is 1.11.1, but I countered the problem of charset garbling (for Chinese) > > <img alt="Image" width="1815" height="363" src="https://private-user-images.githubusercontent.com/50443358/537426860-779e8081-17bf-4b3f-af96-abbcfefc9f8d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njg4MDY3NTIsIm5iZiI6MTc2ODgwNjQ1MiwicGF0aCI6Ii81MDQ0MzM1OC81Mzc0MjY4NjAtNzc5ZTgwODEtMTdiZi00YjNmLWFmOTYtYWJiY2ZlZmM5ZjhkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAxMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMTE5VDA3MDczMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMwZmQzNTkwMDljY2RkOWY0N2VjM2ZlMjY3N2JlODk5MDVhZDQ0MGM1ODk2NWVkMGQ4NzM0MjUxZDcxY2Q5NDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0ruixknWobZXQbDSxZMiaJWfZSAl2tQyQOl5oemoWvQ"> > > ### ❌ Actual Behavior > > _No response_ > > if you use requests, you can > > ``` > import requests > > def foo(): > resp = requests.get("xxx") > resp.encoding = "utf8" > return {"results": resp.text} > ``` No,I used the HTTP node like this <img width="2115" height="1011" alt="Image" src="https://github.com/user-attachments/assets/07c71195-6f39-411a-97ee-3f3d28fd5c22" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21755